Paste without protection

General TRichView support forum. Please post your questions here
Post Reply
Marcer
Posts: 31
Joined: Mon Mar 23, 2009 1:54 pm

Paste without protection

Post by Marcer »

Hi,

I copy to clipboard an RVF text included a protection : [rvprStyleProtect, rvprModifyProtect, rvprDeleteProtect, rvprSticking, rvprStickToTop, rvprDoNotAutoSwitch]

Is it possible to remove the protection included in RVF Text on pasting?

Best regards

Marius
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The current version does not have an option for this.
You can paste in a hidden editor, modify its text styles, then insert to the main editor. You can use OnPaste event.

Code: Select all

procedure TMyForm.MainEditorPaste(Sender: TCustomRichViewEdit;
  var DoDefault: Boolean);
begin
  if not hiddeneditor.CanPasteRVF then
    exit;
  hiddeneditor.Clear;
  hiddeneditor.DeleteUnusedStyles(True, True, True);
  hiddeneditor.Format;
  hiddeneditor.Paste;
  for i := 0 to hiddeneditor.Style.TextStyles.Count-1 do
    hiddeneditor.Style.TextStyles[i].Protection := [];
  Stream := TMemoryStream.Create;
  try
    hiddeneditor.SaveRVFToStream(Stream, False); 
    Stream.Position := 0;
    maineditor.InsertRVFFromStreamEd(Stream);
  finally
    Stream.Free;
  end;
  DoDefault := False;
end;
Marcer
Posts: 31
Joined: Mon Mar 23, 2009 1:54 pm

Post by Marcer »

Thanks Sergey!! It's functionnal!!

Best regards!!

Marius
Post Reply