lib

KoStyleStack Class Reference

#include <KoStyleStack.h>

Public Member Functions

 KoStyleStack ()
 KoStyleStack (const char *styleNSURI, const char *foNSURI)
void clear ()
void save ()
void restore ()
void pop ()
void push (const TQDomElement &style)
bool hasAttribute (const TQString &name, const TQString &detail=TQString()) const TDE_DEPRECATED
TQString attribute (const TQString &name, const TQString &detail=TQString()) const TDE_DEPRECATED
bool hasAttributeNS (const char *nsURI, const char *localName, const char *detail=0) const
TQString attributeNS (const char *nsURI, const char *localName, const char *detail=0) const
bool hasChildNode (const TQString &name) const TDE_DEPRECATED
TQDomElement childNode (const TQString &name) const TDE_DEPRECATED
bool hasChildNodeNS (const char *nsURI, const char *localName) const
TQDomElement childNodeNS (const char *nsURI, const char *localName) const
double fontSize () const
TQString userStyleName (const TQString &family) const
TQString userStyleDisplayName (const TQString &family) const
void setTypeProperties (const char *typeProperties)

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.

Constructor & Destructor Documentation

◆ KoStyleStack() [1/2]

KoStyleStack::KoStyleStack ( )

Create a OASIS style stack.

Definition at line 30 of file KoStyleStack.cpp.

◆ KoStyleStack() [2/2]

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.

◆ ~KoStyleStack()

KoStyleStack::~KoStyleStack ( )
virtual

Definition at line 42 of file KoStyleStack.cpp.

Member Function Documentation

◆ attribute()

TQString KoStyleStack::attribute ( const TQString & name,
const TQString & detail = TQString() ) const

Search for the attribute called 'name', starting on top of the stack, and return it.

Definition at line 112 of file KoStyleStack.cpp.

◆ attributeNS()

TQString 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.

◆ childNode()

TQDomElement KoStyleStack::childNode ( const TQString & 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.

◆ childNodeNS()

TQDomElement 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.

◆ clear()

void KoStyleStack::clear ( )

Clears the complete stack.

Definition at line 46 of file KoStyleStack.cpp.

◆ fontSize()

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.

◆ hasAttribute()

bool KoStyleStack::hasAttribute ( const TQString & name,
const TQString & detail = TQString() ) 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.

◆ hasAttributeNS()

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.

◆ hasChildNode()

bool KoStyleStack::hasChildNode ( const TQString & 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.

◆ hasChildNodeNS()

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.

◆ pop()

void KoStyleStack::pop ( )

Removes the style on top of the stack.

Definition at line 75 of file KoStyleStack.cpp.

◆ push()

void KoStyleStack::push ( const TQDomElement & style)

Pushes the new style onto the stack.

Definition at line 84 of file KoStyleStack.cpp.

◆ restore()

void KoStyleStack::restore ( )

Restore the stack to the state it was at the corresponding save() call.

Definition at line 62 of file KoStyleStack.cpp.

◆ save()

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.

◆ setTypeProperties()

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.

◆ userStyleDisplayName()

TQString KoStyleStack::userStyleDisplayName ( const TQString & 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.

◆ userStyleName()

TQString KoStyleStack::userStyleName ( const TQString & 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.


The documentation for this class was generated from the following files: