How to format the imported rtf?

General TRichView support forum. Please post your questions here
Post Reply
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

How to format the imported rtf?

Post by starhu »

Hello,

I need to implement the following scenario in ScaleRichViewEdit:

1.The user opens an rvf document

2.The document can contain many TextStyles, but one of them is called "BasicStyle"

3.The user chooses a RichText file to import

4. I need to import it in the ScaleRichView (SRichViewEdit1.RichViewEdit.LoadRTF)

5.I need to format the imported text with "BasicStyle" text style.


- I don't know how to find a text style by name. The ApplyTextStyle has an Integer parameter but the order of the "BasicStyle" can vary time to time

- I also don't know how to apply the style to the imported Rtf text

Can you help me? Thank you very much in advance
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Code: Select all

StyleNo := -1;

for i := 0 to SRichViewEdit.RichViewEdit.Style.TextStyles.Count-1 do
  if SRichViewEdit.RichViewEdit.Style.TextStyles[i].StyleName = 'BasicStyle' then begin
    StyleNo := i;
    exit;
  end;
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

Post by starhu »

Hello,

Unfortunately it doesn't work for me. I sent an email with the details.

Thank you very much!
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I received and answered your email.

Styles from RTF are loaded not in TextStyles/ParaStyles, but in StyleTemplates (if UseStyleTemplates=True)
starhu
Posts: 49
Joined: Fri Jan 17, 2014 6:33 pm

Post by starhu »

The big problem is that MainForm.ActiveEditor.RichViewEdit.LoadRTF seems to delet the StyleTemplates of the document (before LoadRTF I can list them, after LoadRTF there is only the "Normal").

How can I avoid it?

Thank you very much!
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Answered in email.
Briefly, the simplest way is using insertion methods instead of loading methods.
Post Reply