Is there a way to track TRVStyle changes?

General TRichView support forum. Please post your questions here
Post Reply
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Is there a way to track TRVStyle changes?

Post by edwinyzh »

Hi Sergey,

Sorry for the several posts, I know you are in vacation, take your time :)

Is there a way to track changes of all the style templates, para styles, text styles and list styles in a TRVStyle object?

Currently all I can find is TCustomRichView.OnStyleTemplatesChange, but it doesn't seem to be enough.

Because I need know if I need to save the content of TRVStyle to INI, if none of the styles were changed obviously I don't need to perform the saving which takes time.

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Is there a way to track TRVStyle changes?

Post by Sergey Tkachenko »

Normally, while editing or inserting files, there is only one change: adding new styles.
Two events are called: TRichView.OnAddStyle or TRVAControlPanel.OnAddStyle (if you use RichViewActions)
Styles can also be replaced from RVF, cleared or deleted as unused. There are no special events, but it happens only on File|New and Open, so you can track these operations.
I do not remember if RichViewXML calls TRichView.OnAddStyle.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is there a way to track TRVStyle changes?

Post by edwinyzh »

So in other words, OnAddStyle is all I need?
Sergey Tkachenko wrote: Tue Jul 12, 2022 1:49 pm I do not remember if RichViewXML calls TRichView.OnAddStyle.
I did a search, RichViewXML does NOT calls TRichView.OnAddStyle. Would you fix it? Thanks.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Is there a way to track TRVStyle changes?

Post by Sergey Tkachenko »

Yes, but TRichView.OnAddStyle and TRVAControlPanel.OnAddStyle are called on different operations, so if you use RichViewActions, you need them both.
Ok, I'll change TRichViewXML. Please note that it will be called only if styles are merged, and not called when they are replaced.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is there a way to track TRVStyle changes?

Post by edwinyzh »

Sergey Tkachenko wrote: Wed Jul 13, 2022 3:39 pm Ok, I'll change TRichViewXML. Please note that it will be called only if styles are merged, and not called when they are replaced.
Thanks! But is there a way to also track when the styles are replaced/changed? Because obviously in that case the styles also need to be saved.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is there a way to track TRVStyle changes?

Post by edwinyzh »

I also want to confirm - OnAddStyle can track all text-related and all style-related operations in a TRichViewEditor that might change content of the associated TRvStyle, correct?
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Is there a way to track TRVStyle changes?

Post by Sergey Tkachenko »

Yes, except for:
- operations on new/open documents
- modifying style templates in dialogs (unlike all other editing operations, modified styletemplates are applied to existing styles instead of addition of new styles)
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is there a way to track TRVStyle changes?

Post by edwinyzh »

Sergey Tkachenko wrote: Thu Jul 14, 2022 10:44 am - modifying style templates in dialogs (unlike all other editing operations, modified styletemplates are applied to existing styles instead of addition of new styles)
I think I can modify the related dialog and track the style template changes for this scenario.
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Is there a way to track TRVStyle changes?

Post by Sergey Tkachenko »

I can add an event which will be called after applying new StyleTemplates.
edwinyzh
Posts: 104
Joined: Sun Jun 05, 2022 2:22 pm

Re: Is there a way to track TRVStyle changes?

Post by edwinyzh »

That'll be great! Thanks!
Post Reply