Page 1 of 1

Is there a way to track TRVStyle changes?

Posted: Tue Jul 12, 2022 9:40 am
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.

Re: Is there a way to track TRVStyle changes?

Posted: Tue Jul 12, 2022 1:49 pm
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.

Re: Is there a way to track TRVStyle changes?

Posted: Wed Jul 13, 2022 2:54 am
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.

Re: Is there a way to track TRVStyle changes?

Posted: Wed Jul 13, 2022 3:39 pm
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.

Re: Is there a way to track TRVStyle changes?

Posted: Thu Jul 14, 2022 1:07 am
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.

Re: Is there a way to track TRVStyle changes?

Posted: Thu Jul 14, 2022 1:29 am
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?

Re: Is there a way to track TRVStyle changes?

Posted: Thu Jul 14, 2022 10:44 am
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)

Re: Is there a way to track TRVStyle changes?

Posted: Thu Jul 14, 2022 12:33 pm
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.

Re: Is there a way to track TRVStyle changes?

Posted: Sat Jul 16, 2022 8:35 am
by Sergey Tkachenko
I can add an event which will be called after applying new StyleTemplates.

Re: Is there a way to track TRVStyle changes?

Posted: Sun Jul 17, 2022 2:07 am
by edwinyzh
That'll be great! Thanks!