insert text!

General TRichView support forum. Please post your questions here
Post Reply
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

insert text!

Post by mohsen24000 »

Hi Dear
I want insert my content of Richview to dbase such as SQLite.
and I want detect my footnotes in document on dbase with "[F]"
for example:
in richview:
"If you do not want to add a poll to your topic1, leave the fields blank."
in dbase:
"If you do not want to add a poll to your topic[F], leave the fields blank."
also, I want insert document on dbase to Richview with replacement '[F]'
and it's footnote that saved in dbase.
thanks a lot.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not completely understand the question.

Do you want to save documents as they are, with all available formatting, but save text "[F]" instead of footnotes?
What saving format do you use, RTF or RVF?

Is it really necessary to replace footnotes and then inserting them back? What if the user will type "[F]" in the document itself?

You can, for example, save a document with empty footnotes, then fill them from DB when necessary.
mohsen24000
Posts: 75
Joined: Fri Jan 06, 2012 8:13 pm

Post by mohsen24000 »

for example:

Code: Select all

var ItemNo: integer;
ctext: TStringList;
begin
for ItemNo := 0 to R_Q.ItemCount - 1 do begin
if R_Q.GetItem(ItemNo) is TCustomRVNoteItemInfo then
 begin
  R_Q.SetSelectionBounds(ItemNo, R_Q.GetOffsBeforeItem(ItemNo),
   ItemNo, R_Q.GetOffsBeforeItem(ItemNo));
  R_Q.inserttext('[F]');
 end;
end;
R_Q.BeginUpdate;
R_Q.SelectAll;
try
ctext:= TStringList.Create;
ctext.Text:= Trim(R_Q.GetSelTextW);
R_Q.Deselect;
R_Q.EndUpdate;
...
insert ctext items into dbase
...
finally
freeandnil(ctext);
end;
end;
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can use OnSaveItemToFile event to save footnotes as '[F]' in text:

Code: Select all

uses RVUni;
procedure TForm3.RichViewEdit1SaveItemToFile(Sender: TCustomRichView;
  const Path: string; RVData: TCustomRVData; ItemNo: Integer;
  SaveFormat: TRVSaveFormat; Unicode: Boolean; var OutStr: TRVRawByteString;
  var DoDefault: Boolean);
begin
  if (SaveFormat=rvsfText) and (RVData.GetItemStyle(ItemNo)=rvsFootnote) then begin
    OutStr := '[F]';
    if Unicode then
      OutStr := RVU_AnsiToUnicode(CP_ACP, OutStr);
    DoDefault := False;
  end;
end;
Post Reply