lib
KoGenStyles Class Reference
#include <KoGenStyles.h>
Detailed Description
Repository of styles used during saving of OASIS/OOo file.Each instance of KoGenStyles is a collection of styles whose names are in the same "namespace". This means there should be one instance for all styles in <office:styles>, and automatic-styles, another instance for number formats, another one for draw styles, and another one for list styles.
"Style" in this context only means "a collection of properties". The "Gen" means both "Generic" and "Generated" :)
The basic design principle is the flyweight pattern: if you need a style with the same properties from two different places, you get the same object. Here it means rather you get the same name for the style, and it will get saved only once to the file.
KoGenStyles features sharing, creation on demand, and name generation. Since this is used for saving only, it doesn't feature refcounting, nor removal of individual styles.
NOTE: the use of KoGenStyles isn't mandatory, of course. If the application is already designed with user and automatic styles in mind for a given set of properties, it can go ahead and save all styles directly (after ensuring they have unique names).
- Author:
- David Faure <faure@kde.org>
Definition at line 59 of file KoGenStyles.h.
Public Types | |
typedef QMap< KoGenStyle, QString > | StyleMap |
enum | Flags { NoFlag = 0, ForceNumbering = 0, DontForceNumbering = 1 } |
Public Member Functions | |
KoGenStyles () | |
~KoGenStyles () | |
QString | lookup (const KoGenStyle &style, const QString &name=QString::null, int flags=NoFlag) |
const StyleMap & | styles () const |
QValueList< NamedStyle > | styles (int type, bool markedForStylesXml=false) const |
const KoGenStyle * | style (const QString &name) const |
KoGenStyle * | styleForModification (const QString &name) |
void | markStyleForStylesXml (const QString &name) |
void | dump () |
Classes | |
struct | NamedStyle |
Member Enumeration Documentation
|
Those are flags for the lookup() call. By default, the generated style names will look like "name1", "name2". If DontForceNumbering is set, the first name that will be tried is "name", and only if that one exists, then "name1" is tried. Set DontForceNumbering if the name given as argument is supposed to be the full style name. Definition at line 74 of file KoGenStyles.h. |
Member Function Documentation
|
Outputs debug information.
Definition at line 139 of file KoGenStyles.cpp. |
|
Look up a style in the collection, inserting it if necessary. This assigns a name to the style and returns it.
Definition at line 32 of file KoGenStyles.cpp. |
|
Mark a given automatic style as being needed in styles.xml. For instance styles used by headers and footers need to go there, since they are saved in styles.xml, and styles.xml must be independent from content.xml. Equivalent to using KoGenStyle::setAutoStyleInStylesDotXml() but this can be done after lookup. This operation can't be undone; once styles are promoted they can't go back to being content.xml-only.
Definition at line 131 of file KoGenStyles.cpp. |
|
Definition at line 115 of file KoGenStyles.cpp. |
|
Definition at line 126 of file KoGenStyles.cpp. |
|
Return all styles of a given type Use this for saving the styles.
Definition at line 100 of file KoGenStyles.cpp. |
|
Return the entire collection of styles Use this for saving the styles.
Definition at line 104 of file KoGenStyles.h. |
The documentation for this class was generated from the following files: