I use fields in my RVE templates and then replace them with values from my database. In RVE 22.4 I have special routines to replace a field with multiple lines of text. That part is stumping me due to the change of the item from RichViewTextItemClass to RVItemFactory.TextItemClass.
Specifically these lines are inaccessible:
item.ParaNo := ParaNo;
item.StyleNo := itemStyleNo;
Its part of a procedure that is part of this routine shown below: ReplaceItemWithMemo(RVData: TCustomRVFormattedData; var ItemIndex: integer): Boolean;
The entire ugly procedure is listed below, hope you can help. It is called by a procedure from your FillFields examples.
Code: Select all
// Memo Fields must be treated differently, can't just replace item text, must delete
// item and then add each line in the memo field as an RVitem. Get the DB field in
// a TStringList to make it easy.
function TDocEditor.ReplaceItemWithMemo(RVData: TCustomRVFormattedData; var ItemIndex: integer): Boolean;
var ParaNo: Integer;
BR, ContinuePara: Boolean;
vStringList: TStringList;
s: TRVUniCodeString;
j: Integer;
item: TRVTextItemInfoClass;
itemStyleNo: integer;
vField: TField;
IsAddress: boolean;
begin
Result := True;
vStringList := nil;
vField := dmMerge.GetField(FFieldInfo);
if vField <> nil then
dmMerge.CheckMoveNext(vField, FFieldInfo);
// storing parameters of item to be deleted
ParaNo := RVData.GetItemPara(ItemIndex);
BR := RVData.GetItem(ItemIndex).BR;
ContinuePara := RVData.GetItem(ItemIndex).SameAsPrev;
itemStyleNo := RVData.GetItemStyle(ItemIndex);
//Address may or may not contain crlf's
//if none then just replace value and return
//else replace with first line and then add others below
if (AnsiContainsText(FFieldInfo.FieldName, cADDRESS)) then
begin
IsAddress := true;
vStringList := TStringList.Create();
vStringList.Text := dmMerge.GetFieldValue(FFieldInfo);
if vStringList.Count < 2 then
begin
SetItemValue(ItemIndex, RVData, vStringList.Text);
vStringList.Free;
exit;
end else
if (SameText(FFieldInfo.TableName, cVENDOR)) then
//don't do this for the Vendor Calculated Address field
//because it causes a blank line between address fields.
//Don't know if this is needed for other non memo address fields.
begin
Inc(ItemIndex);
end else
begin
SetItemValue(ItemIndex, RVData, vStringList[0]);
vStringList[0] := ''; //forces a line break
Inc(ItemIndex);
end;
end else
begin
IsAddress := false;
RVData.DeleteItems(ItemIndex,1);
end;
if (SameText(FFieldInfo.FieldName, cTERMS)) then
begin
InsertFieldIntoRVF(RVData, dmMerge.QtQry, dmMerge.QtQryTerms, ItemIndex);
exit;
end;
try
if (IsAddress) then
begin
// vStringList will contain 2nd line +
end else
vStringList := dmMerge.GetMemoField(FFieldInfo);
if (vStringList = Nil) then exit;
if (vStringList.Count = 0) then
vStringList.Add(' ');
//InsertMultilineText(RVData, i, j, vStringList.Text);
for j := vStringList.Count-1 downto 0 do
begin
item := RVItemFactory.TextItemClass;
s := ReplaceCRLFWithSpaces(vStringList[j]);
if IsAddress then
if s = '' then
continue;
item.ParaNo := ParaNo;
item.StyleNo := itemStyleNo;
if j=0 then
begin
item.SameAsPrev := ContinuePara;
item.BR := BR;
end;
item.Inserting(RVData, s, False);
try
RVData.Items.InsertObject(ItemIndex, s, item);
item.Inserted(RVData, ItemIndex);
except
end;
NormalizeRichView(RVData);
end;
finally
if Assigned(vStringList) then
vStringList.Free;
end;
ApplySavedParams(RVData, ContinuePara, BR, ParaNo, ItemIndex);
end;