AppendRVFFromStream

General TRichView support forum. Please post your questions here
Post Reply
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

AppendRVFFromStream

Post by jgkoehn »

Greetings,
I need to use AppendRVFFromStream to append a footnote into a table.
It is working excellently in the regular text. But when I try to append into a table it places the footnote before the table. Ideas as to how to fix this?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: AppendRVFFromStream

Post by Sergey Tkachenko »

Please post your code for appending to a table.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: AppendRVFFromStream

Post by jgkoehn »

It is a modified version that I use in rvhtmlimport (I did a custom version)
Basically near the end: FViewer.AppendRVFFromStream(msRVE,-1);

Code: Select all

//Inserting a footnote from Sergey's code
procedure TJGKRvHtmlImporter.CustomFootnoteInsert(ms: TMemoryStream);
var
   FootNote: TRVFootnoteItemInfo;
   NoteRef:  TRVNoteReferenceItemInfo;
   Crve: TRichViewEdit;
   msRVE: TMemoryStream;
 begin
  Crve := TRichViewEdit.Create(nil);
  Crve.Style := TRVStyle.Create(nil);
  Crve.Visible:= False;
  Crve.Parent := FViewer;
  Crve.Style := FViewer.Style;
  Crve.Clear;

  FootNote := TRVFootnoteItemInfo.CreateEx(Crve.RVData,
      RVStyleFindFont('Segoe UI', clBlue, 10, [], rvsssSuperScript, False),
      1, False);
  NoteRef := TRVNoteReferenceItemInfo.CreateEx(FootNote.Document,
    RVGetNoteTextStyleNo(FViewer.Style, 0));
  FootNote.Document.AddItem('', NoteRef);
  FootNote.Document.AddNL(' ', 0, -1);
  FootNote.Document.LoadRVFFromStream(ms);
  Crve.InsertItem('' ,FootNote);
  Crve.Format;

  msRVE := TMemoryStream.Create;
  Crve.SaveRVFToStream(msRVE,False);
  msRVE.Position := 0;
  //Append footnote number into content
  FViewer.AppendRVFFromStream(msRVE,-1);
  msRVE.Clear;

  Crve.Free;
  msRVE.Free;
end;                          
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: AppendRVFFromStream

Post by Sergey Tkachenko »

But you append the document to the end of FViewer, not in a table.
If you need to append to a table cell, call Table.Cell[r,c].AppendRVFFromStream

PS: LoadRVFFromStream clears footnote document before loading, removing a note reference and a space character. AppendRVFFromStream would be useful here

PPS: Format is not needed after InsertItem. InsertItem is an editing method, it requires a formatted document before its call, and leaves the document formatted.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: AppendRVFFromStream

Post by jgkoehn »

Ah thanks I'll have to see if there is someway I can get the table information it is in. Yes to the end of the FViewer wherever the converted html/xhtml is at at that time in rvhtmlimport. But perhaps I can get it to tell me if it is in a table. I will email you so it makes more sense
This is in rvhtmlimport so somethings are quite interesting if you remember that document.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: AppendRVFFromStream

Post by Sergey Tkachenko »

In RvHtmlImporter, there is FRVData field that contains the current document. It may be the main document, or a cell (when reading table).

You do not need a temporal TRichViewEdit, you do not need AppendRVFFromStream.
Simply pass FRVData in the constructor of TRVFootnoteItemInfo, and add it using FRVData.AddItem method.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: AppendRVFFromStream

Post by jgkoehn »

Thank you for your patience on this.
So I have an array of RichView streams: GTagRVFStrArray.ms_rv
I need to make them into a footnote and then add it.

I am sure there is a much better way to do this.
What I am doing at present is finding the data that needs put into footnotes. Saving it as a RichView that is put into a stream to keep formatting.
Then I find the pair of that data later on in a secondary loop through the overall content. Now I bring the data out of the string put it in a footnote format and add it.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: AppendRVFFromStream

Post by jgkoehn »

Steps basically:
basically grab text with format > save to RV stream array > find it when we need it from the array > convert to Footnote > add/insert it correctly
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: AppendRVFFromStream

Post by jgkoehn »

Thanks for the help sir!
Post Reply