#include <KoGenStyles.h>
Types publics | |
enum | Flags { NoFlag = 0, ForceNumbering = 0, DontForceNumbering = 1 } |
typedef QMap< KoGenStyle, QString > | StyleMap |
Fonctions membres publiques | |
KoGenStyles () | |
~KoGenStyles () | |
QString | lookup (const KoGenStyle &style, const QString &name=QString::null, int flags=NoFlag) |
const StyleMap & | styles () const |
Q3ValueList< 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 () |
Types privés | |
typedef QMap< QString, bool > | NameMap |
typedef Q3ValueVector< NamedStyle > | StyleArray |
List of styles (used to preserve ordering). | |
Fonctions membres privées | |
QString | makeUniqueName (const QString &base, int flags) const |
Attributs privés | |
StyleMap | m_styleMap |
style definition -> name | |
NameMap | m_styleNames |
NameMap | m_autoStylesInStylesDotXml |
StyleArray | m_styleArray |
Private * | d |
Classes | |
struct | NamedStyle |
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).
Définition à la ligne 60 du fichier KoGenStyles.h.
typedef QMap<KoGenStyle, QString> KoGenStyles::StyleMap |
Définition à la ligne 100 du fichier KoGenStyles.h.
typedef QMap<QString, bool> KoGenStyles::NameMap [private] |
Map with the style name as key. This map is mainly used to check for name uniqueness The value of the bool doesn't matter.
Définition à la ligne 164 du fichier KoGenStyles.h.
typedef Q3ValueVector<NamedStyle> KoGenStyles::StyleArray [private] |
enum KoGenStyles::Flags |
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.
Définition à la ligne 75 du fichier KoGenStyles.h.
KoGenStyles::KoGenStyles | ( | ) |
Définition à la ligne 26 du fichier KoGenStyles.cpp.
KoGenStyles::~KoGenStyles | ( | ) |
Définition à la ligne 30 du fichier KoGenStyles.cpp.
QString KoGenStyles::lookup | ( | const KoGenStyle & | style, | |
const QString & | name = QString::null , |
|||
int | flags = NoFlag | |||
) |
Look up a style in the collection, inserting it if necessary. This assigns a name to the style and returns it.
style | the style to look up. | |
name | proposed (base) name for the style. Note that with the OASIS format, the style name is never shown to the user (there's a separate display-name attribute for that). So there are little reasons to use named styles anyway. But this attribute can be used for clarity of the files. If this name is already in use (for another style), then a number is appended to it until unique. | |
flags | see Flags |
Définition à la ligne 34 du fichier KoGenStyles.cpp.
Références KoGenStyle::autoStyleInStylesDotXml(), DontForceNumbering, KoGenStyle::m_attributes, m_autoStylesInStylesDotXml, KoGenStyle::m_familyName, KoGenStyle::m_parentName, m_styleArray, m_styleMap, m_styleNames, KoGenStyle::m_type, makeUniqueName(), KoGenStyles::NamedStyle::name, KoGenStyle::parentName(), KoGenStyles::NamedStyle::style, et style().
Référencé par KoTextParag::saveOasis(), KoOasisStyles::saveOasisCurrencyStyle(), KoOasisStyles::saveOasisDateStyle(), KoOasisStyles::saveOasisFractionStyle(), KoOasisStyles::saveOasisHatchStyle(), KoOasisStyles::saveOasisNumberStyle(), KoOasisStyles::saveOasisPercentageStyle(), KoOasisStyles::saveOasisScientificStyle(), KoOasisStyles::saveOasisTextStyle(), KoOasisStyles::saveOasisTimeStyle(), KoParagStyle::saveStyle(), testDefaultStyle(), testLookup(), testStylesDotXml(), et testUserStyles().
Voici le graphe d'appel pour cette fonction :
Voici le graphe d'appel pour cette fonction :
const StyleMap& KoGenStyles::styles | ( | ) | const [inline] |
Return the entire collection of styles Use this for saving the styles
Définition à la ligne 105 du fichier KoGenStyles.h.
Référencé par testDefaultStyle(), testLookup(), et testUserStyles().
Voici le graphe d'appel pour cette fonction :
Q3ValueList< KoGenStyles::NamedStyle > KoGenStyles::styles | ( | int | type, | |
bool | markedForStylesXml = false | |||
) | const |
Return all styles of a given type Use this for saving the styles
type | the style type, see the KoGenStyle constructor | |
markedForStylesXml | if true, return only style marked for styles.xml, otherwise only those NOT marked for styles.xml. |
Définition à la ligne 102 du fichier KoGenStyles.cpp.
Références m_autoStylesInStylesDotXml, m_styleArray, et m_styleNames.
const KoGenStyle * KoGenStyles::style | ( | const QString & | name | ) | const |
Définition à la ligne 117 du fichier KoGenStyles.cpp.
Références m_styleArray.
Référencé par dump(), lookup(), styleForModification(), testLookup(), et KoGenStyle::writeStyle().
Voici le graphe d'appel pour cette fonction :
KoGenStyle * KoGenStyles::styleForModification | ( | const QString & | name | ) |
Définition à la ligne 128 du fichier KoGenStyles.cpp.
Références style().
Référencé par markStyleForStylesXml(), et KoStyleCollection::saveOasis().
Voici le graphe d'appel pour cette fonction :
Voici le graphe d'appel pour cette fonction :
void KoGenStyles::markStyleForStylesXml | ( | const QString & | name | ) |
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.
Définition à la ligne 133 du fichier KoGenStyles.cpp.
Références m_autoStylesInStylesDotXml, m_styleNames, KoGenStyle::setAutoStyleInStylesDotXml(), et styleForModification().
Référencé par testLookup().
Voici le graphe d'appel pour cette fonction :
Voici le graphe d'appel pour cette fonction :
void KoGenStyles::dump | ( | ) |
Outputs debug information
Définition à la ligne 141 du fichier KoGenStyles.cpp.
Références KoGenStyle::autoStyleInStylesDotXml(), m_autoStylesInStylesDotXml, m_styleArray, m_styleNames, et style().
Voici le graphe d'appel pour cette fonction :
QString KoGenStyles::makeUniqueName | ( | const QString & | base, | |
int | flags | |||
) | const [private] |
Définition à la ligne 85 du fichier KoGenStyles.cpp.
Références DontForceNumbering, m_autoStylesInStylesDotXml, m_styleNames, et KoPageFormat::name().
Référencé par lookup().
Voici le graphe d'appel pour cette fonction :
Voici le graphe d'appel pour cette fonction :
StyleMap KoGenStyles::m_styleMap [private] |
style definition -> name
Définition à la ligne 159 du fichier KoGenStyles.h.
Référencé par lookup().
NameMap KoGenStyles::m_styleNames [private] |
Définition à la ligne 165 du fichier KoGenStyles.h.
Référencé par dump(), lookup(), makeUniqueName(), markStyleForStylesXml(), et styles().
Définition à la ligne 166 du fichier KoGenStyles.h.
Référencé par dump(), lookup(), makeUniqueName(), markStyleForStylesXml(), et styles().
StyleArray KoGenStyles::m_styleArray [private] |
Private* KoGenStyles::d [private] |
Définition à la ligne 172 du fichier KoGenStyles.h.