AddPictureEx at the right position - not to the end
Posted: Fri Mar 15, 2013 12:33 pm
Im searching a text (aText) in a RVReportHelper.RichView.RVData (aRVData) and try to replace it with an image (from aFileName). But my procedure puts the image to the end of the document... what can i use to insert the pic at the right position?
Code: Select all
procedure RVImportPic(aRVData: TCustomRVData; aFileName, aText: string);
for i := 0 to aRVData.ItemCount-1 do
if aRVData.GetItemStyle(i)=rvsTable then begin
table := TRVTableItemInfo(aRVData.GetItem(i));
for r := 0 to table.Rows.Count-2 do
for c := 0 to table.Rows[r].Count-1 do
if table.Cells[r,c] <> nil then
RVImportPic(table.Cells[r,c].GetRVData, aFileName, aText);
end
else if aRVData.GetItemStyle(i) >= 0 then
if Pos(aText, aRVData.GetItemText(i)) > 0 then begin
newtext := StringReplace(aRVData.GetItemText(i), aText, '', [rfReplaceAll, rfIgnoreCase]);
if newtext = '' then
aRVData.DeleteItems(i, 1)
else
aRVData.SetItemText(i, newtext);
aPic:= TPicture.Create;
if FileExists(aFileName) then
begin
aPic.LoadFromFile(aFileName);
aRVData.AddPictureEx(aText, aPic.Graphic, -1, rvvaBaseline);
end;
end;