Lose bold formatting in case of using rvfoUseStyleNames

General TRichView support forum. Please post your questions here
Post Reply
Manfred Gahr
Posts: 13
Joined: Wed Aug 19, 2009 1:12 pm

Lose bold formatting in case of using rvfoUseStyleNames

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Manfred Gahr
Posts: 13
Joined: Wed Aug 19, 2009 1:12 pm

Post 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
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
Post Reply