Page 1 of 1

How to format the imported rtf?

Posted: Mon Apr 28, 2014 9:35 am
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

Posted: Mon Apr 28, 2014 2:24 pm
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;

Posted: Sun May 11, 2014 4:09 pm
by starhu
Hello,

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

Thank you very much!

Posted: Mon May 12, 2014 8:16 am
by Sergey Tkachenko
I received and answered your email.

Styles from RTF are loaded not in TextStyles/ParaStyles, but in StyleTemplates (if UseStyleTemplates=True)

Posted: Mon May 12, 2014 11:42 am
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!

Posted: Fri May 16, 2014 11:49 am
by Sergey Tkachenko
Answered in email.
Briefly, the simplest way is using insertion methods instead of loading methods.