footnote problem
Posted: Sun Nov 19, 2023 12:02 pm
Hello everyone,
please help me with a footnote problem.
I have two modes for the documents, the normal one (TRichViewEdit) or the pagewise one (TSRichViewEdit). The user can choose which one he prefers to write with.
Unfortunately, I cannot insert footnotes in TSRichViewEdit. If I use the code from the help, the footnote is created correctly with number 1 at the bottom of the page, but I cannot edit it. I also get GPFs immediately.
By the way, I can't use RichViewActions, the reason is a bit complicated.
So you can't create new footnotes in TSRichViewEdit, but only in the standard (TRichViewEdit), that's no drama now. Here is the code that works well:
But now I still have two problems:
1. when I switch to the TSRichViewEdit, no numbers are visible at the bottom of the page
2. if I change the footnote text in TSRichViewEdit, the text in the footnote (without number - is this related?) is not updated, even if I use UpdateBuffer.
please help me with a footnote problem.
I have two modes for the documents, the normal one (TRichViewEdit) or the pagewise one (TSRichViewEdit). The user can choose which one he prefers to write with.
Unfortunately, I cannot insert footnotes in TSRichViewEdit. If I use the code from the help, the footnote is created correctly with number 1 at the bottom of the page, but I cannot edit it. I also get GPFs immediately.
By the way, I can't use RichViewActions, the reason is a bit complicated.
Code: Select all
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, ve.CurTextStyleNo), 1, False);
// filling Note.Document: adding a footnote number and a space character
NoteRef := TRVNoteReferenceItemInfo.CreateEx(Note.Document, VGetNoteTextStyleNo(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;
Code: Select all
procedure TfMain.InsertFootNote;
var FootN: TRVFootnoteItemInfo;
NoteRef: TRVNoteReferenceItemInfo;
begin
FootN := TRVFootnoteItemInfo.CreateEx(CurrRV.RVData, FootnoteStyle(False, CurrRV.CurTextStyleNo, CurrRV.Style), 1, False);
NoteRef := TRVNoteReferenceItemInfo.CreateEx(FootN.Document, RVGetNoteTextStyleNo(rvs,0));
FootN.Document.AddItem('', NoteRef);
FootN.Document.AddNL('', 0, -1);
if CurrRV.InsertItem('', FootN) and (CurrRV.GetCurrentItem is TCustomRVNoteItemInfo) then
// Own window for entering the text
EditFootNote(CurrRV.GetCurrentItem as TCustomRVNoteItemInfo);
end;
1. when I switch to the TSRichViewEdit, no numbers are visible at the bottom of the page
2. if I change the footnote text in TSRichViewEdit, the text in the footnote (without number - is this related?) is not updated, even if I use UpdateBuffer.