List Index Out Of Bounds When Inserting Bitmap
Posted: Wed May 02, 2012 10:51 am
I have been using the following code to replace the selection with a bitmap image:
procedure MergeFieldToBitmap(var Bmp: TBitmap; const ImgName: string; const StretchX,StretchY: Integer);
var
info: TRVGraphicItemInfo;
s, SplitText: TRVRawByteString;
begin
re.DeleteSelection;
info := TRVGraphicItemInfo.CreateEx(RVData, Bmp, rvvaBaseline);
info.ImageWidth := Bmp.Width * StretchX;
info.ImageHeight := Bmp.Height * StretchY;
s := RVU_GetRawUnicode(ImgName);
SplitText := '';
TRVEditRVData(re.RVData).InsertSomething(info, s, SplitText, False, False, True);
Bmp := nil;
end; {MergeFieldToBitmap}
Having upgraded to the latest version this code now causes a list index out of bounds error on the InsertSomething command.
The error is raised in unit RVERVData on line 1919
As follows:
then begin
info.SameAsPrev := True;
info.ParaNo := GetItemPara(DrawItems[CaretDrawItemNo].ItemNo); //< HERE
end
else begin
CaretDrawItemNo = -1
Crucially the code is called before the form is displayed. Is there a fix/workaround for this?
procedure MergeFieldToBitmap(var Bmp: TBitmap; const ImgName: string; const StretchX,StretchY: Integer);
var
info: TRVGraphicItemInfo;
s, SplitText: TRVRawByteString;
begin
re.DeleteSelection;
info := TRVGraphicItemInfo.CreateEx(RVData, Bmp, rvvaBaseline);
info.ImageWidth := Bmp.Width * StretchX;
info.ImageHeight := Bmp.Height * StretchY;
s := RVU_GetRawUnicode(ImgName);
SplitText := '';
TRVEditRVData(re.RVData).InsertSomething(info, s, SplitText, False, False, True);
Bmp := nil;
end; {MergeFieldToBitmap}
Having upgraded to the latest version this code now causes a list index out of bounds error on the InsertSomething command.
The error is raised in unit RVERVData on line 1919
As follows:
then begin
info.SameAsPrev := True;
info.ParaNo := GetItemPara(DrawItems[CaretDrawItemNo].ItemNo); //< HERE
end
else begin
CaretDrawItemNo = -1
Crucially the code is called before the form is displayed. Is there a fix/workaround for this?