Page 1 of 1

Lose bold formatting in case of using rvfoUseStyleNames

Posted: Mon Apr 25, 2011 7:58 am
by Manfred Gahr
Hello Sergey,

If we enable option rvfoUseStyleNames (rvfoSave***Styles are disabled) and mark some text as bold then after Save to file / Re-open bold formatting is lost. If rvfoUseStyleNames is disabled then everything is OK. Any thoughts about it?

Thanks

Posted: Mon Apr 25, 2011 8:39 am
by Sergey Tkachenko
If rvfoUseStyleNames is included in RVFOptions, names of styles are saved in RVF files instead of their indices. This mode works correctly only if all styles have unique names.
I do not recommend using this mode.

Posted: Mon Apr 25, 2011 11:18 am
by Manfred Gahr
Hello Sergey,

Thank you for fast reply. Yes, we understand how it is supposed to work and we use it intentionally. We have dedicated collection of styles which is stored in DB. It is assumed that styles will be added and removed time to time, therefore we can't use indeces due to possible style shifting in case of removing style from the middle of collection. Well, if you don't recommend using that approach maybe you can suggest some alternative?

Back to my initial question:
If I undertstand you right, when:
- rvfoUseStyleNames is disabled then indeces are used
- rvfoUseStyleNames is enabled then style names are used

However, if I mark some text as bold (using RV action, not special style) and save content to a file then bold formatting is lost (i.e. ...bold text... become ...bold text...) if rvfoUseStyleNames is included. If rvfoUseStyleNames is not included then everything is OK, i.e. ...bold text... remains ...bold text... after loading to RichView. It shouldn't happen if difference only in identification of styles. How can we avoid this behavior?

Thanks

Posted: Mon Apr 25, 2011 5:53 pm
by Sergey Tkachenko
When you apply formatting, such as bold, a new style (or styles) may be created. They are added to the end of TextStyles/ParaStyles/ListStyles collection. They have the same name as the styles they are based on.
So, after applying "bold" to some text, you now have two styles with the same names.

How to avoid this problem?
You can process RVAControlPanel.OnAddStyle event. In this event, you can assign a unique name to a style created by RichViewActions.
See also TRichView.OnAddStyle