footnote problem

General TRichView support forum. Please post your questions here
Post Reply
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

footnote problem

Post by Jim Knopf »

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.

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;
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:

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;
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.
Jim Knopf
Posts: 241
Joined: Mon Dec 30, 2013 10:07 pm
Location: Austria
Contact:

Re: footnote problem

Post by Jim Knopf »

No idea ...?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: footnote problem

Post by Sergey Tkachenko »

Sorry for the delay, and sorry, I cannot reproduce the problem.

I tested in ScaleRichView\Demos\Delphi\Editor\ demo.

The first code fragment works fine.

The second code fragment has your custom functions, but after changing it to

Code: Select all

  CurrRV := SRichViewEdit1.RichViewEdit.TopLevelEditor;
  FootN := TRVFootnoteItemInfo.CreateEx(CurrRV.RVData, RVGetNoteTextStyleNo(CurrRV.Style, CurrRV.CurTextStyleNo), 1, False);
  NoteRef := TRVNoteReferenceItemInfo.CreateEx(FootN.Document, RVGetNoteTextStyleNo(CurrRV.Style,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);
it works fine as well.
(the only difference that I can see, the first code fragment starts editing the note, then immediately ends it; there is no effect other than scrolling to the note and back)

Do you use the newest version of ScaleRichView? If not, please upgrade.
If yes, please send me a simple compileable project to reproduce the problem.
Post Reply