Hello,
How can I save a set of styles to database fields? I am a bit lost on this one (probably it's right in my face but I can't see it).
Let me explain the problem: I am diong a app where my client (the administrator of the app) has a set of one or more styles that can be used in some documents, so he creates the style and it is saved to a database field (a blob). Other users with edit documents and will be permitted to use only one of the styles previously saved, if not defined the app with apply the "default" style automatically (determined by the administrator).
I have been trying to do this but I can't get to save/retrive the styles in databse rows.
Thanks
Andrew
Saving styles into a DB
-
- Posts: 22
- Joined: Thu Sep 30, 2010 8:49 pm
- Location: Brazil
-
- Site Admin
- Posts: 17609
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 22
- Joined: Thu Sep 30, 2010 8:49 pm
- Location: Brazil
Yes, sort of.
I have the TRvStyle object attached to my TDbRichViewEdit object by the Style property.
So, I need to save the Text Styles (TFontInfos, TParaInfos and TRvListInfos preferrebly) to Database rows and I need to be able to retrieve them, see/list the set to a report and be able to force the document that is being edited to one particular style determined by the client, so, when the user is editing the text, it will be using the specified font and with a specific paragraf indentation and whatever else I can save/retrive.
Ex: If the client specifies that the text will only use Arial 14 Italic with 2 cm of first line indentation it will be applied to this document and the end user won't be able to change this.
The client wants to be able to change the style of the text depending on specific conditions in the app.
I have been trying to do this but I can't manage to make it work... is this possible? Or is there another way to do this?
I have the TRvStyle object attached to my TDbRichViewEdit object by the Style property.
So, I need to save the Text Styles (TFontInfos, TParaInfos and TRvListInfos preferrebly) to Database rows and I need to be able to retrieve them, see/list the set to a report and be able to force the document that is being edited to one particular style determined by the client, so, when the user is editing the text, it will be using the specified font and with a specific paragraf indentation and whatever else I can save/retrive.
Ex: If the client specifies that the text will only use Arial 14 Italic with 2 cm of first line indentation it will be applied to this document and the end user won't be able to change this.
The client wants to be able to change the style of the text depending on specific conditions in the app.
I have been trying to do this but I can't manage to make it work... is this possible? Or is there another way to do this?
-
- Site Admin
- Posts: 17609
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Posts: 22
- Joined: Thu Sep 30, 2010 8:49 pm
- Location: Brazil
-
- Site Admin
- Posts: 17609
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
1. How to save collections of TextStyles, ParaStyles, ListStyles
Option 1:
Properties TRVStyle, including collections, can be saved to ini-file using the method SaveINI (and loaded using LoadINI).
Minus: file-related methods, additional code is needed if you want to store in a database.
Option 2:
You can write the content of TRVStyle to a stream using TWriter.WriteComponent
(you can write only collections using WriteCollection, but I do not think it makes sense).
In this way, you can store data in BLOB field via a stream.
If you need an example, let me know.
Option 3:
Simply store empty RVF document with these styles, and load this document before loading the actual documents from DB
2. How to restrict formatting
Right click the editor, choose "Options" in the context menu, select "Use a predefined set of styles".
The properties will be set to the following values:
- collections of styles will not be saved to RVF
- when inserting RVF or RTF (for example, pasting from the Clipboard), formatting is mapped to the most similar existing formatting.
I assume, collections of styles may be edited while they are already used in documents, so a correspondence between styles and documents must be maintained.
There are two options.
- (default) documents in DB refer to styles using indexes in collections; admins can modify and add styles, but cannot delete them, because it would damage the correspondence
- documents in DB refer to styles using their names (StyleName propertis); include rvfoUseStyleNames in RVFOptions to activate this option; admins can add, modify, delete and reorder styles, but you must provide that all styles in collections have unique names.
Option 1:
Properties TRVStyle, including collections, can be saved to ini-file using the method SaveINI (and loaded using LoadINI).
Minus: file-related methods, additional code is needed if you want to store in a database.
Option 2:
You can write the content of TRVStyle to a stream using TWriter.WriteComponent
(you can write only collections using WriteCollection, but I do not think it makes sense).
In this way, you can store data in BLOB field via a stream.
If you need an example, let me know.
Option 3:
Simply store empty RVF document with these styles, and load this document before loading the actual documents from DB
2. How to restrict formatting
Right click the editor, choose "Options" in the context menu, select "Use a predefined set of styles".
The properties will be set to the following values:
- collections of styles will not be saved to RVF
- when inserting RVF or RTF (for example, pasting from the Clipboard), formatting is mapped to the most similar existing formatting.
I assume, collections of styles may be edited while they are already used in documents, so a correspondence between styles and documents must be maintained.
There are two options.
- (default) documents in DB refer to styles using indexes in collections; admins can modify and add styles, but cannot delete them, because it would damage the correspondence
- documents in DB refer to styles using their names (StyleName propertis); include rvfoUseStyleNames in RVFOptions to activate this option; admins can add, modify, delete and reorder styles, but you must provide that all styles in collections have unique names.