How to mix default styles with user custom styles?

General TRichView support forum. Please post your questions here
Post Reply
lbreysse
Posts: 11
Joined: Sat Apr 09, 2011 12:31 am

How to mix default styles with user custom styles?

Post by lbreysse »

Hello,

I use the style templates capabilities of TRichView to support standard styles, loaded from rvst file.
I need to save the richview document with references to template styles, when they are used, and user customized styles (for exemple, when the user apply bullets to a paragraph, previously formatted with a template style), but I'm unuable to find a suitable configuration of the TRichView component to do so.

Here is how my RichView components are setup:
ARichView.UseStyleTemplates := True;

ARichView.RVFParaStylesReadMode := rvf_sInsertMap;
ARichView.RVFTextStylesReadMode := rvf_sInsertMap;
ARichView.RVFOptions := [
rvfoConvUnknownStylesToZero,
rvfoSaveBinary,
// rvfoSaveParaStyles,
// rvfoSaveTextStyles,
rvfoSaveDocProperties,
rvfoSavePicturesBody
];

With this setup, bullets are not saved.
If I activate rvfoSaveParaStyle, bullets are saved but when I update the standard template style, it is not automatically applied to the document.
I'd like to save bullets, but still inherit for template styles directly.

Do you have any clue on how I could achieve that?

Many thanks,
Laurent
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to mix default styles with user custom styles?

Post by Sergey Tkachenko »

I am not sure that I understand the problem.

RVFOptions affect only saving and loading.
If you want to save ListStyles, you must include rvfoSaveParaStyles.
If you want to save StyleTemplates, you must include both rvfoSaveTextStyles and rvfoSaveParaStyles.

If you want to modify StyleTemplates and apply changes, you need to create a copy of StyleTemplates, modify this copy, then call ChangeStyleTemplates, see the help file: http://www.trichview.com/help/idh_trich ... lates.html
lbreysse
Posts: 11
Joined: Sat Apr 09, 2011 12:31 am

Re: How to mix default styles with user custom styles?

Post by lbreysse »

To summarize my need:
I need to save files as small as possible.
For that, I have defined a standard set of template styles, saved in a rvts file, and customizable by the end user.
I need to save styles created by the richview component (for example, when importing a msword file), but not standard defined styles.

Is there a way to do that?

Thanks & Regards,
Laurent
lbreysse
Posts: 11
Joined: Sat Apr 09, 2011 12:31 am

Re: How to mix default styles with user custom styles?

Post by lbreysse »

Thank you Sergey
I'll use external text and para style instead of template styles, like I did in another software (it worked well but I had to code an equivalent of the style templates and related RVStyleTemplateListBox component)

Best Regards,
Laurent
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: How to mix default styles with user custom styles?

Post by Sergey Tkachenko »

Actually, there is a possibility to use StyleTemplates and all the standard editor UI, and still not saving TextStyles, ParaStyles and ListStyles in RVF.
As I understand, in your previous solution, you used common collections of styles for all documents, and store them outside RVF documents.
You can do the same, you just need to store collections after editing, because editing will change them. You can use methods of TRVStyle for saving to INI files or to the Registry.

You can use StyleTemplates, you can leave *ReadMode = rvf_sInsertMerge.

However, it requires a careful programming. Adding new styles is not a problem, because it does not affect existing documents. But deleting styles must be prohibited, because documents contain indexes in style collections, and they will be incorrect.
If you use RichViewActions, you cannot use TrvActionNew and TrvActionOpen, because, if UseStyleTemplates = True, they delete existing styles and fill the style collections with default values.
If you use TDBRichViewEdit, assign its AutoDeleteUnusedStyles = False.
You must not call DeleteUnusedStyles. However, to prevent accumulation of unneeded styles, you should implement deleting them, but for all documents at once. See http://www.trichview.com/help/idh_class ... sdata.html
Post Reply