lib
KoStyleStack Class Reference
#include <KoStyleStack.h>
Detailed Description
This class implements a stack for the different styles of an object.There can be several styles that are valid for one object. For example a textobject on a page has styles 'pr3' and 'P7' and a paragraph in that textobject has styles 'P1' and 'T3'. And some styles even have parent-styles...
If you want to know if there is, for example, the attribute 'fo:font-family' for this paragraph, you have to look into style 'T3', 'P1', 'P7' and 'pr3'. When you find this attribute in one style you have to stop processing the list and take the found attribute for this object.
This is what this class does. You can push styles on the stack while walking through the xml-tree to your object and then ask the stack if any of the styles provides a certain attribute. The stack will search from top to bottom, i.e. in our example from 'T3' to 'pr3' and return the first occurrence of the wanted attribute.
So this is some sort of inheritance where the styles on top of the stack overwrite the same attribute of a lower style on the stack.
In general though, you wouldn't use push/pop directly, but KoOasisLoadingContext::fillStyleStack or KoOasisLoadingContext::addStyles to automatically push a style and all its parent styles onto the stack.
Definition at line 59 of file KoStyleStack.h.
Public Member Functions | |
KoStyleStack () | |
KoStyleStack (const char *styleNSURI, const char *foNSURI) | |
void | clear () |
void | save () |
void | restore () |
void | pop () |
void | push (const QDomElement &style) |
bool | hasAttribute (const QString &name, const QString &detail=QString::null) const KDE_DEPRECATED |
QString | attribute (const QString &name, const QString &detail=QString::null) const KDE_DEPRECATED |
bool | hasAttributeNS (const char *nsURI, const char *localName, const char *detail=0) const |
QString | attributeNS (const char *nsURI, const char *localName, const char *detail=0) const |
bool | hasChildNode (const QString &name) const KDE_DEPRECATED |
QDomElement | childNode (const QString &name) const KDE_DEPRECATED |
bool | hasChildNodeNS (const char *nsURI, const char *localName) const |
QDomElement | childNodeNS (const char *nsURI, const char *localName) const |
double | fontSize () const |
QString | userStyleName (const QString &family) const |
QString | userStyleDisplayName (const QString &family) const |
void | setTypeProperties (const char *typeProperties) |
Constructor & Destructor Documentation
KoStyleStack::KoStyleStack | ( | ) |
KoStyleStack::KoStyleStack | ( | const char * | styleNSURI, | |
const char * | foNSURI | |||
) |
Create a style stack based on other namespaces than OASIS - used for OOo-1.1 import.
Definition at line 36 of file KoStyleStack.cpp.
Member Function Documentation
void KoStyleStack::clear | ( | void | ) |
void KoStyleStack::save | ( | ) |
Save the current state of the stack.
Any items added between this call and its corresponding restore() will be removed when calling restore().
Definition at line 54 of file KoStyleStack.cpp.
void KoStyleStack::restore | ( | ) |
Restore the stack to the state it was at the corresponding save() call.
Definition at line 62 of file KoStyleStack.cpp.
void KoStyleStack::pop | ( | ) |
void KoStyleStack::push | ( | const QDomElement & | style | ) |
bool KoStyleStack::hasAttribute | ( | const QString & | name, | |
const QString & | detail = QString::null | |||
) | const |
Check if any of the styles on the stack has an attribute called 'name'-'detail' where detail is e.g.
left, right, top or bottom. This allows to also find 'name' alone (e.g. padding implies padding-left, padding-right etc.)
Definition at line 92 of file KoStyleStack.cpp.
QString KoStyleStack::attribute | ( | const QString & | name, | |
const QString & | detail = QString::null | |||
) | const |
Search for the attribute called 'name', starting on top of the stack, and return it.
Definition at line 112 of file KoStyleStack.cpp.
bool KoStyleStack::hasAttributeNS | ( | const char * | nsURI, | |
const char * | localName, | |||
const char * | detail = 0 | |||
) | const |
Check if any of the styles on the stack has an attribute called 'name'-'detail' where detail is e.g.
left, right, top or bottom. This allows to also find 'name' alone (e.g. padding implies padding-left, padding-right etc.)
Definition at line 154 of file KoStyleStack.cpp.
QString KoStyleStack::attributeNS | ( | const char * | nsURI, | |
const char * | localName, | |||
const char * | detail = 0 | |||
) | const |
Search for the attribute called 'name', starting on top of the stack, and return it.
Definition at line 133 of file KoStyleStack.cpp.
bool KoStyleStack::hasChildNode | ( | const QString & | name | ) | const |
Check if any of the styles on the stack has a child node called 'name'.
Definition at line 198 of file KoStyleStack.cpp.
QDomElement KoStyleStack::childNode | ( | const QString & | name | ) | const |
Search for a child node called 'name', starting on top of the stack, and return it.
Definition at line 212 of file KoStyleStack.cpp.
bool KoStyleStack::hasChildNodeNS | ( | const char * | nsURI, | |
const char * | localName | |||
) | const |
Check if any of the styles on the stack has a child element called 'localName' in the namespace 'nsURI'.
Definition at line 227 of file KoStyleStack.cpp.
QDomElement KoStyleStack::childNodeNS | ( | const char * | nsURI, | |
const char * | localName | |||
) | const |
Search for a child element which has a child element called 'localName' in the namespace 'nsURI' starting on top of the stack, and return it.
Definition at line 241 of file KoStyleStack.cpp.
double KoStyleStack::fontSize | ( | ) | const |
Special case for the current font size, due to special handling of fo:font-size="115".
Definition at line 177 of file KoStyleStack.cpp.
QString KoStyleStack::userStyleName | ( | const QString & | family | ) | const |
Return the name of the style specified by the user, i.e.
not an auto style. This is used to know e.g. which user-style is associated with the current paragraph. There could be none though.
Definition at line 266 of file KoStyleStack.cpp.
QString KoStyleStack::userStyleDisplayName | ( | const QString & | family | ) | const |
Return the display name of the style specified by the user, i.e.
not an auto style
Definition at line 280 of file KoStyleStack.cpp.
void KoStyleStack::setTypeProperties | ( | const char * | typeProperties | ) |
Set the type of properties that will be looked for.
For instance setTypeProperties("paragraph") will make hasAttribute() and attribute() look into "paragraph-properties". If typeProperties
is 0, the stylestack is resetted to look for "properties" as it does by default.
Definition at line 293 of file KoStyleStack.cpp.
The documentation for this class was generated from the following files: