Strange exception of TSRichViewEdit.SubDocuments

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

Strange exception of TSRichViewEdit.SubDocuments

Post 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;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Strange exception of TSRichViewEdit.SubDocuments

Post by Sergey Tkachenko »

Can you create a simple project reproducing this problem?
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

Re: Strange exception of TSRichViewEdit.SubDocuments

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Strange exception of TSRichViewEdit.SubDocuments

Post 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).
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

Re: Strange exception of TSRichViewEdit.SubDocuments

Post by wolf1860 »

Copy it ! thanks a lot:)
Post Reply