Page 1 of 1

AppendRVFFromStream

Posted: Tue Mar 30, 2021 11:08 pm
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?

Re: AppendRVFFromStream

Posted: Wed Mar 31, 2021 5:35 am
by Sergey Tkachenko
Please post your code for appending to a table.

Re: AppendRVFFromStream

Posted: Wed Mar 31, 2021 4:32 pm
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;                          

Re: AppendRVFFromStream

Posted: Wed Mar 31, 2021 5:38 pm
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.

Re: AppendRVFFromStream

Posted: Wed Mar 31, 2021 9:07 pm
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.

Re: AppendRVFFromStream

Posted: Thu Apr 01, 2021 10:38 am
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.

Re: AppendRVFFromStream

Posted: Thu Apr 01, 2021 5:22 pm
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.

Re: AppendRVFFromStream

Posted: Thu Apr 01, 2021 5:42 pm
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

Re: AppendRVFFromStream

Posted: Thu Apr 01, 2021 9:00 pm
by jgkoehn
Thanks for the help sir!