Footnotes and endnotes

Overview

Top  Previous  Next

TSRichViewEdit control can edit documents with footnotes and endnotes.

When a footnote or endnote is being edited, its Document is loaded in TSRichViewEdit.RVNote, ActiveEditor becomes equal to RVNote, CurrentNote returns this footnote/endnote item.

Limitation: Document of footnote/endnote must not be higher than one page.

Footnotes and endnotes in RichViewActions

a_footnote TsrvActionInsertFootnote inserts a footnote.

a_endnote TsrvActionInsertEndnote inserts an endnote.

a_blank TsrvActionEditNote starts editing a footnote/endnote.

a_blank TsrvActionReturnToNote moves the caret to the parent footnote/endnote.

Editing footnotes and endnotes without RichViewActions

Inserting a new footnote in SRichViewEdit1:

var Note: TRVFootnoteItemInfo;

    NoteRef: TRVNoteReferenceItemInfo;

    rve: TCustomRichViewEdit;

 

// we can insert a footnote only in the main document

rve := SRichViewEdit1.ActiveEditor;

if rve<>SRichViewEdit1.RichViewEdit then

  exit;

// we will use item indices, so we require the top level editor

rve := rve.TopLevelEditor;

// creating a footnote

Note := TRVFootnoteItemInfo.CreateEx(rve.RVData, RVGetNoteTextStyleNo(rve.Style, rve.CurTextStyleNo), 1, False);

// filling Note.Document: adding a footnote number and a space character

NoteRef := TRVNoteReferenceItemInfo.CreateEx(Note.Document, RVGetNoteTextStyleNo(rve.Style, 0));

Note.Document.AddItem('', NoteRef);

Note.Document.AddNL(' ', 0, -1);

// inserting

if rve.InsertItem('', Note) then begin

  // preparing for displaying in TSRichViewEdit

  SRichViewEdit1.UpdateNote(rve.RVData, rve.CurItemNo);

  // starting editing the inserted footnote

  SRichViewEdit1.StartEditNote(rve.RVData, rve.CurItemNo);

  // moving the caret to the end of the Note.Document

  rve := SRichViewEdit1.ActiveEditor// now rv = SRichViewEdit.RVNote

  rve.SetSelectionBounds(rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1),

    rve.ItemCount-1, rve.GetOffsAfterItem(rve.ItemCount-1));

end;

Returning from RVNote to the parent footnote/endnote:

  SRichViewEdit1.ReturnToNote;


ScaleRichView © Ilya Zelensky & Sergey Tkachenko