A Way to Update Style Templates After Changes?
A Way to Update Style Templates After Changes?
Hi Sergey,
OK, let's say I create a style template: st1. I open or create an RVF and apply the st1 to some text, then save the file. All that works fine.
Now, while the file is closed, let's say I change some parameters of st1 in Delphi. Now, I reopen that saved file again in my app. Any st1 text in that file has the old parameters since it was saved that way.
Now, is there a way from code to update any old instances of st1 in that file to the new parameters of the updated st1 without manually selecting it and reapplying the st1 template again?
Edit: I see UpdateModifiedTextStyleProperties, UpdateModifiedParaStyleProperties in the help file. Would that be the way?
Just curious, this is not a big deal but I thought I'd ask just in case.
Stan
OK, let's say I create a style template: st1. I open or create an RVF and apply the st1 to some text, then save the file. All that works fine.
Now, while the file is closed, let's say I change some parameters of st1 in Delphi. Now, I reopen that saved file again in my app. Any st1 text in that file has the old parameters since it was saved that way.
Now, is there a way from code to update any old instances of st1 in that file to the new parameters of the updated st1 without manually selecting it and reapplying the st1 template again?
Edit: I see UpdateModifiedTextStyleProperties, UpdateModifiedParaStyleProperties in the help file. Would that be the way?
Just curious, this is not a big deal but I thought I'd ask just in case.
Stan
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: A Way to Update Style Templates After Changes?
Was this file saved with rvfoSaveStyleTemplatesOnlyNames in RVFOptions?
If yes, no additional code is required, everything is performed automatically.
In this demo, modified StyleTemplates are applied when loading records, without any additional code.
RVF contains information about properties of TextStyles and ParaStyle, values of which of them were taken from StyleTemplates, and values of which of them were changed on top of StyleTemplates. Values of the first group of properties are changed according to the changed StyleTemplates.
If yes, no additional code is required, everything is performed automatically.
In this demo, modified StyleTemplates are applied when loading records, without any additional code.
RVF contains information about properties of TextStyles and ParaStyle, values of which of them were taken from StyleTemplates, and values of which of them were changed on top of StyleTemplates. Values of the first group of properties are changed according to the changed StyleTemplates.
Re: A Way to Update Style Templates After Changes?
Hi Sergey,
OK, I'm using rvfoSaveStyleTemplatesOnlyNames and so far, yes, that seems to work.
Thanks!
Stan
OK, I'm using rvfoSaveStyleTemplatesOnlyNames and so far, yes, that seems to work.
Thanks!
Stan
Re: A Way to Update Style Templates After Changes?
Does `rvfoSaveStyleTemplatesOnlyNames ` work the same with documents saved in XML with `TRichViewXML`?Sergey Tkachenko wrote: ↑Wed Aug 18, 2021 10:46 am Was this file saved with rvfoSaveStyleTemplatesOnlyNames in RVFOptions?
If yes, no additional code is required, everything is performed automatically.
In this demo, modified StyleTemplates are applied when loading records, without any additional code.
RVF contains information about properties of TextStyles and ParaStyle, values of which of them were taken from StyleTemplates, and values of which of them were changed on top of StyleTemplates. Values of the first group of properties are changed according to the changed StyleTemplates.
I mean, I too need to share a single TRVStyle with multiple documents, I use SaveTo/LoadFromIni to persist the styles and style templates.
This will work, right?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: A Way to Update Style Templates After Changes?
This option is not implemented in RVXML yet.
I'll do it in one of future updates.
I'll do it in one of future updates.
Re: A Way to Update Style Templates After Changes?
Oh, bad news for me! Because I use XML instead of rvf as the persisting format...Sergey Tkachenko wrote: ↑Wed Jun 15, 2022 9:19 am This option is not implemented in RVXML yet.
I'll do it in one of future updates.
Any other features of rvf persistence not available in XML persistence?
And more importantly, how can I implement one shared TRVStyle object for multiple documents in my case?
Thanks.
Re: A Way to Update Style Templates After Changes?
To be more specific, I guess the following 3 properties are related to shared styles for multiple documents:edwinyzh wrote: ↑Wed Jun 15, 2022 9:39 amOh, bad news for me! Because I use XML instead of rvf as the persisting format...Sergey Tkachenko wrote: ↑Wed Jun 15, 2022 9:19 am This option is not implemented in RVXML yet.
I'll do it in one of future updates.
Any other features of rvf persistence not available in XML persistence?
And more importantly, how can I implement one shared TRVStyle object for multiple documents in my case?
Thanks.
StyleTemplateInsertMode, RvfTextStylesReadMode, RvfParaStylesReadMode.
Does XML format respect all these properties?
Thanks.
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: A Way to Update Style Templates After Changes?
You can use the same TRVStyle and RichViewXML.
If RichViewXML.SaveStyles = False, properties of TRVStyle is not saved to XML, including collections of styles.
(but if it is True, all properties of TRVStyle are saved, unlike RVF).
When loading XML containing styles, RichViewXML.StyleLoadingMode is used, this is the analog of RVFTextStylesReadMode and RVFTextStylesReadMode.
Normally, RichViewXML documents contain the same information as RVF and even more.
For example:
- as I said, it can contain all properties of TRVStyle
- if SaveBackground = True, it saves not only background but layout properties, but also Options, RTFOptions, EditorOptions
- it contains images from ImageLists (instead of requesting them in an event)
If RichViewXML.SaveStyles = False, properties of TRVStyle is not saved to XML, including collections of styles.
(but if it is True, all properties of TRVStyle are saved, unlike RVF).
When loading XML containing styles, RichViewXML.StyleLoadingMode is used, this is the analog of RVFTextStylesReadMode and RVFTextStylesReadMode.
Normally, RichViewXML documents contain the same information as RVF and even more.
For example:
- as I said, it can contain all properties of TRVStyle
- if SaveBackground = True, it saves not only background but layout properties, but also Options, RTFOptions, EditorOptions
- it contains images from ImageLists (instead of requesting them in an event)
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: A Way to Update Style Templates After Changes?
RichView.StyleTemplateInsertMode property is respected by RichViewXML
Re: A Way to Update Style Templates After Changes?
Great! So in order to achieve "shared-style-for-multi-documents", I should use slmMap for RichViewXML.StyleLoadingMode, right?Sergey Tkachenko wrote: ↑Wed Jun 15, 2022 10:02 am When loading XML containing styles, RichViewXML.StyleLoadingMode is used, this is the analog of RVFTextStylesReadMode and RVFTextStylesReadMode.
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: A Way to Update Style Templates After Changes?
It depends on what you want from shared styles.
1.a. You can save documents without TextStyles, ParaStyles, ListStyles.
This option is useful if you have a hard-coded predefined set of styles that are used in multiple documents. Usually, in this mode, each item in TextStyles and ParaStyles has its own meaning. You cannot use UI for applying arbitrary text and paragraph attributes (such as RichViewActions), because they add new text and paragraph styles.
Property settings for this option: RichViewXML.SaveStyles = False.
In this mode, value of StyleLoadingMode is not so important, because it defines how styles from XML document are used, but your documents will not contain styles. More important to prevent new styles from appearing when inserting/pasting RVF, RTF and DocX files.
1.b. Actually, a set of styles is not necessary must be predefined. You can modify it (but you need to make sure that indexes of styles in documents remain correct), and save styles separately from documents (TRVStyle.SaveINI).
There are two reasons for using this mode:
- smaller file sizes
- each TextStyle and ParaStyle may have specific meaning, and can be customized.
2. Shared StyleTemplates (that are not implemented in RichViewXML yet) are completely different. Unlike the methods (1), they do not restrict text and paragraph formatting.
Collections of TextStyles, ParaStyles, and ListStyles must be saved in documents.
You can use UI for applying arbitrary text and paragraph attributes, including RichViewActions.
The only shared thing is a collection of StyleTemplates (that should be stored outside of documents, TRVStyle.SaveToRVST).
StyleTemplates are not used by text items and paragraphs directly (unlike TextStyles and ParaStyles). Instead, StyleTemplates are linked to items of TextStyles and ParaStyles and allow modify them. Shared StyleTemplates can modify multiple documents (they are applied on loading).
1.a. You can save documents without TextStyles, ParaStyles, ListStyles.
This option is useful if you have a hard-coded predefined set of styles that are used in multiple documents. Usually, in this mode, each item in TextStyles and ParaStyles has its own meaning. You cannot use UI for applying arbitrary text and paragraph attributes (such as RichViewActions), because they add new text and paragraph styles.
Property settings for this option: RichViewXML.SaveStyles = False.
In this mode, value of StyleLoadingMode is not so important, because it defines how styles from XML document are used, but your documents will not contain styles. More important to prevent new styles from appearing when inserting/pasting RVF, RTF and DocX files.
1.b. Actually, a set of styles is not necessary must be predefined. You can modify it (but you need to make sure that indexes of styles in documents remain correct), and save styles separately from documents (TRVStyle.SaveINI).
There are two reasons for using this mode:
- smaller file sizes
- each TextStyle and ParaStyle may have specific meaning, and can be customized.
2. Shared StyleTemplates (that are not implemented in RichViewXML yet) are completely different. Unlike the methods (1), they do not restrict text and paragraph formatting.
Collections of TextStyles, ParaStyles, and ListStyles must be saved in documents.
You can use UI for applying arbitrary text and paragraph attributes, including RichViewActions.
The only shared thing is a collection of StyleTemplates (that should be stored outside of documents, TRVStyle.SaveToRVST).
StyleTemplates are not used by text items and paragraphs directly (unlike TextStyles and ParaStyles). Instead, StyleTemplates are linked to items of TextStyles and ParaStyles and allow modify them. Shared StyleTemplates can modify multiple documents (they are applied on loading).
Re: A Way to Update Style Templates After Changes?
My requirement is like #2, but in addition to sharing StyleTemplates between documents, both TextStyles and ParaStyles need to be shared too.
Moreover, I need to use the UI (richViewActions) and let the user apply/change the styles as usual.
Yes, I'm using `TRVStyle.SaveToINI` (should be same as TRVStyle.SaveToRVST?)
Do you think I can achieve the above goal?
Moreover, I need to use the UI (richViewActions) and let the user apply/change the styles as usual.
Yes, I'm using `TRVStyle.SaveToINI` (should be same as TRVStyle.SaveToRVST?)
Do you think I can achieve the above goal?
-
- Site Admin
- Posts: 17555
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: A Way to Update Style Templates After Changes?
Well, in this case you do not need the "shared StyleTemplates" feature.
The purpose of shared StyleTemplates: a single collection of StyleTemplates is used by multiple collections of TextStyles and ParaStyles.
But, as I understand, you want to use the same collections of TextStyles and ParaStyles (and ListStyles, and StyleTemplates) for all documents.
In this case, a simple not-saving styles to XML does this work.
Styles must be saved outside of documents (the simplest way is using RVStyle.SaveINI/LoadINI; these methods save everything, including collection of styles and StyleTemplates).
You want to use arbitrary text attributes when editing. Ok, it's not a problem. All editing operation on styles only add new styles, so indexes of styles in existing documents remain valid. Just do not forget to call RVStyle.SaveINI to store updates collections of styles.
After some time, there may be a problem: too many styles, some of them are not used in any document, and you may wish to optimize them.
You cannot use RichView.DeleteUnusedStyles, because it does not work properly for styles used in multiple documents.
However, this problem can be solved, see TRVDeleteUnusedStylesData
Notes:
1. I assume that only one of documents that use shared styles is displayed and edited at any time. Otherwise, you will need to solve additional problems.
2. Make sure that you do not use operations that replace collections of styles (loading RVF and XML with options of replacing styles)
The purpose of shared StyleTemplates: a single collection of StyleTemplates is used by multiple collections of TextStyles and ParaStyles.
But, as I understand, you want to use the same collections of TextStyles and ParaStyles (and ListStyles, and StyleTemplates) for all documents.
In this case, a simple not-saving styles to XML does this work.
Styles must be saved outside of documents (the simplest way is using RVStyle.SaveINI/LoadINI; these methods save everything, including collection of styles and StyleTemplates).
You want to use arbitrary text attributes when editing. Ok, it's not a problem. All editing operation on styles only add new styles, so indexes of styles in existing documents remain valid. Just do not forget to call RVStyle.SaveINI to store updates collections of styles.
After some time, there may be a problem: too many styles, some of them are not used in any document, and you may wish to optimize them.
You cannot use RichView.DeleteUnusedStyles, because it does not work properly for styles used in multiple documents.
However, this problem can be solved, see TRVDeleteUnusedStylesData
Notes:
1. I assume that only one of documents that use shared styles is displayed and edited at any time. Otherwise, you will need to solve additional problems.
2. Make sure that you do not use operations that replace collections of styles (loading RVF and XML with options of replacing styles)
Re: A Way to Update Style Templates After Changes?
Very detailed info and instruction, I appreciate it!
Yes, as you said, I "want to use the same collections of TextStyles and ParaStyles (and ListStyles, and StyleTemplates) for all documents."
And this is how I'm currently trying to implement it:
- In the program I have only a single instance of TRVStyle managed by a data module, its content is saved to and loaded from INI, as you said.
- I have multiple "editor forms" that has a TRichViewEdit which links to the same TRVStyle object described above.
- The "editor form" is copied and modified from "\TRichView\RichViewActions\Demos\DelphiUnicode\ActionTest"
- So each of these "editor forms" also has a `TRVStyleTemplateComboBox` which I need.
Does my design above makes sense?
And I assume all the TRVStyleTemplateComboBox instances on multiple "editor forms" uses the same "shared StyleTemplates" from that single TRVStyle instance. Am I correct?
Do you think my above design allows this possibility? What additional problems will I have?
Thank you again!
Yes, as you said, I "want to use the same collections of TextStyles and ParaStyles (and ListStyles, and StyleTemplates) for all documents."
And this is how I'm currently trying to implement it:
- In the program I have only a single instance of TRVStyle managed by a data module, its content is saved to and loaded from INI, as you said.
- I have multiple "editor forms" that has a TRichViewEdit which links to the same TRVStyle object described above.
- The "editor form" is copied and modified from "\TRichView\RichViewActions\Demos\DelphiUnicode\ActionTest"
- So each of these "editor forms" also has a `TRVStyleTemplateComboBox` which I need.
Does my design above makes sense?
I'm not sure if we are talking about the same thing, but since TRVStyle loads and saves StyleTemplates, and since I use only a single TRVStyle in the entire program, it's "shared StyleTemplates", isn't it?in this case you do not need the "shared StyleTemplates" feature
And I assume all the TRVStyleTemplateComboBox instances on multiple "editor forms" uses the same "shared StyleTemplates" from that single TRVStyle instance. Am I correct?
Actually, I'm planning to have multiple "editor forms" managed by TPageControl, while only one is visible at the same time, there are multiple "editor form" instances at the same time.I assume that only one of documents that use shared styles is displayed and edited at any time. Otherwise, you will need to solve additional problems.
Do you think my above design allows this possibility? What additional problems will I have?
Thank you again!