trichview.com

trichview.support




Re: GetItem - AddItem - Table


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/15/2005 18:05:48


No, this code will not work, because both doc and doc2 will attempt to free

memory for table, and the program will crash.

It's not possible to move (without tricks), but it's possible to copy:


var i : integer;

    table, table2 : TRVTableItemInfo;

    Stream: TMemoryStream;

begin

   for i := doc.ItemCount - 1 downto 0 do

   begin

      if doc.GetItemStyle(i) = rvsTable then

      begin

          table := TRVTableItemInfo (doc.getItem(i));

          Stream := TMemoryStream.Create;

          table.SaveToStream(Stream);

          Stream.Position := 0;

          table2 := TRVTableItemInfo.CreateEx(1, 1, doc2.RVData);

          table2.LoadFromStream(Stream);

          doc2.AddItem('table' + inttostr(cont), table2);

      end;

   end;

end;


table.SaveToStream/LoadFromStream use RVF format to store cells contents, so

doc's and doc2's RVF-related properties are important.


If doc and doc2 are linked to the same RVStyle component, set

doc2.RVFTextStylesReadMode = doc2.RVFParaStylesReadMode = rvf_sIgnore.


If doc and doc2 are linked to different RVStyle components, set

doc2.RVFTextStylesReadMode = doc2.RVFParaStylesReadMode = rvf_sInsertMerge,

and

include [rvfoSaveTextStyles, rvfoSaveParaStyles] in doc.RVFOptions

(Or simply right click in doc in Delphi, choose "Settings" in the context

menu, then set "Allow adding styles dynamically". Then do the same with

doc2)





Powered by ABC Amber Outlook Express Converter