Scribus
Open source desktop publishing at your fingertips
StyleStack Class Reference

#include <stylestack.h>

Public Types

enum  Mode { OODraw1x = 1, OODraw2x = 2 }
 

Public Member Functions

void setMode (const StyleStack::Mode mode)
 
void clear ()
 
void save ()
 
void restore ()
 
void pop ()
 
void push (const QDomElement &style)
 
bool hasAttribute (const QString &name) const
 
QString attribute (const QString &name) const
 
bool hasAttribute (const QString &name, const QString &detail) const
 
QString attribute (const QString &name, const QString &detail) const
 
bool hasChildNode (const QString &name) const
 
QDomNode childNode (const QString &name) const
 
double fontSize () const
 
QString userStyleName () const
 

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.

Member Function Documentation

QString StyleStack::attribute ( const QString &  name) const

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

QString StyleStack::attribute ( const QString &  name,
const QString &  detail 
) const

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

QDomNode StyleStack::childNode ( const QString &  name) const

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

void StyleStack::clear ( void  )

Clears the complete stack.

double StyleStack::fontSize ( ) const

Special case for the current font size, due to special handling of fo:font-size="115%".

bool StyleStack::hasAttribute ( const QString &  name) const

Check if any of the styles on the stack has an attribute called 'name'.

bool StyleStack::hasAttribute ( const QString &  name,
const QString &  detail 
) 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.)

bool StyleStack::hasChildNode ( const QString &  name) const

Check if any of the styles on the stack has a child node called 'name'.

void StyleStack::pop ( )

Removes the style on top of the stack.

void StyleStack::push ( const QDomElement &  style)

Pushes the new style onto the stack.

void StyleStack::restore ( )

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

void StyleStack::save ( )

Save the current state of the stack. Any items added between this call and its corresponding restore() will be removed when calling restore().

void StyleStack::setMode ( const StyleStack::Mode  mode)

Set attribute analysis mode.

QString StyleStack::userStyleName ( ) const

Return the name of the style specified by the user, i.e. not an auto style


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