<< Click to display table of contents >> Notes and text boxes |
TSRichViewEdit control can edit documents with footnotes, endnotes, sidenotes (notes in a floating box) and floating boxes.
When a note or a text box is being edited, its Document is loaded in TSRichViewEdit.RVNote, ActiveEditor becomes equal to RVNote, CurrentNote returns this note/text box item, CurrentNoteParentEditor returns the editor containing this note.
Footnotes and endnotes can be inserted only in the main document. Sidenotes and text box items can be inserted in the main document, headers and footers.
Limitations:
•document of footnote/endnote must not be higher than one page;
•ChangeStyleTemplates must not be called when a note editor is active.
TsrvActionInsertFootnote inserts a footnote.
TsrvActionInsertEndnote inserts an endnote.
TsrvActionInsertSidenote inserts a sidenote.
TsrvActionInsertTextBox inserts a text box item.
TsrvActionEditNote starts editing a note or a text box.
TsrvActionReturnToNote moves the caret to the parent footnote/endnote.
Use the actions above instead of their analogs included in RichViewActions for TRichViewEdit controls.
Inserting a new footnote in SRichViewEdit1 (this example does not use StyleTemplates):
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
// 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;