Page 1 of 1

Strange exception of TSRichViewEdit.SubDocuments

Posted: Wed Mar 11, 2020 1:03 pm
by wolf1860
I handled subdocuments with the following procedure ,sRveExport is a TSRichviewEdit, it worked perfect until today. Exception message is : list index out of bounds(-1),exception only occured on the header file's loading when "loadRVF",the footer file's loading is right,what I missed?

procedure TfrmQuestionExport.HandleSubDocuments;
var
c: TColor;
begin
sRveExport.PageProperty.TitlePage := True;
sRveExport.PageProperty.HeaderVisible := True;
sRveExport.PageProperty.FooterVisible := True;
sRveExport.PageProperty.TitlePage := True;
c := clWhite;

if FileExists(myPath + HeaderFN0) then
sRveExport.SubDocuments.Items[srvhftFirstPageHeader]
.LoadRVF(myPath + HeaderFN0, c, nil, nil);
if FileExists(myPath + HeaderFN) then
sRveExport.SubDocuments.Items[srvhftNormalHeader].LoadRVF(myPath + HeaderFN,
c, nil, nil);

if FileExists(myPath + FooterFN) then
begin
sRveExport.SubDocuments.Items[srvhftFirstPageFooter]
.LoadRVF(myPath + FooterFN, c, nil, nil);
sRveExport.SubDocuments.Items[srvhftNormalFooter].LoadRVF(myPath + FooterFN,
c, nil, nil);
end
else
sRveExport.PageProperty.PageNoVisible := True;
sRveExport.Format;
end;

Re: Strange exception of TSRichViewEdit.SubDocuments

Posted: Wed Mar 11, 2020 3:22 pm
by Sergey Tkachenko
Can you create a simple project reproducing this problem?

Re: Strange exception of TSRichViewEdit.SubDocuments

Posted: Wed Mar 11, 2020 4:10 pm
by wolf1860
Sorry,I forgot the NewItemAction event.
Then,how can I determine if the item is in the subdocuments,or it is in the TSRichviewEdit.RichviewEdit's content?

Re: Strange exception of TSRichViewEdit.SubDocuments

Posted: Wed Mar 11, 2020 5:30 pm
by Sergey Tkachenko
It's not very trivial.

OnItemAction has Sender and RVData parameters.

1) Sender may be SRV.RichViewEdit, SRV.RVHeader, SRV.RVFooter, SRV.RVNote, or a temporal editor used to draw inactive notes and text boxes.
But for SubDocuments, Sender = SRV.RichViewEdit, like for items in the main documents.

2) RVData is a document that contains this item.
It may be:
a) either RVData of the editors listed above (like SRV.RichViewEdit.RVData)
b) or one of SubDocuments[]
c) or a it may be a table cell or a note/textbox document; in this case, you can check RVData.GetAbsoluteParentData (or RVData.GetAbsoluteParentData.GetAbsoluteParentData and so on), until it will be one of (a) or (b).

Re: Strange exception of TSRichViewEdit.SubDocuments

Posted: Thu Mar 12, 2020 6:34 pm
by wolf1860
Copy it ! thanks a lot:)