Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

StyleStack Class Reference

#include <stylestack.h>

List of all members.

Public Types

enum  Mode { OODraw1x = 1, OODraw2x = 2 }

Public Member Functions

 StyleStack ()
virtual ~StyleStack ()
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

Private Member Functions

void fillNodeNameList (QStringList &names, const StyleStack::Mode mode)
QDomElement searchAttribute (const QDomElement &element, const QStringList &names, const QString &name) const
QDomElement searchAttribute (const QDomElement &element, const QStringList &names, const QString &name, const QString &fullName) const

Private Attributes

QStringList m_nodeNames
QStack< int > m_marks
QList< QDomElement > m_stack


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.

Definition at line 58 of file stylestack.h.


Member Enumeration Documentation

Enumerator:
OODraw1x 
OODraw2x 

Definition at line 64 of file stylestack.h.


Constructor & Destructor Documentation

StyleStack::StyleStack (  ) 

Definition at line 32 of file stylestack.cpp.

References clear(), fillNodeNameList(), m_nodeNames, and OODraw1x.

StyleStack::~StyleStack (  )  [virtual]

Definition at line 38 of file stylestack.cpp.


Member Function Documentation

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

Set attribute analysis mode.

Definition at line 42 of file stylestack.cpp.

References fillNodeNameList(), and m_nodeNames.

Referenced by OODPlug::convert().

void StyleStack::clear (  ) 

Clears the complete stack.

Definition at line 48 of file stylestack.cpp.

References m_stack.

Referenced by OODPlug::convert(), and StyleStack().

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().

Definition at line 53 of file stylestack.cpp.

References m_marks, and m_stack.

void StyleStack::restore (  ) 

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

Definition at line 58 of file stylestack.cpp.

References m_marks, and m_stack.

void StyleStack::pop (  ) 

Removes the style on top of the stack.

Definition at line 68 of file stylestack.cpp.

References m_stack.

void StyleStack::push ( const QDomElement &  style  ) 

Pushes the new style onto the stack.

Definition at line 73 of file stylestack.cpp.

References m_stack.

Referenced by OODPlug::addStyles().

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

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

Definition at line 78 of file stylestack.cpp.

References m_nodeNames, m_stack, and searchAttribute().

Referenced by OODPlug::parseCharStyle(), OODPlug::parseParagraphStyle(), OODPlug::parseStyle(), OODPlug::parseTextP(), and OODPlug::parseTextSpans().

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

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

Definition at line 93 of file stylestack.cpp.

References m_nodeNames, m_stack, and searchAttribute().

Referenced by OODPlug::parseCharStyle(), OODPlug::parseParagraphStyle(), and OODPlug::parseStyle().

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

Definition at line 108 of file stylestack.cpp.

References m_nodeNames, m_stack, and searchAttribute().

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.

Definition at line 125 of file stylestack.cpp.

References m_nodeNames, m_stack, and searchAttribute().

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

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

Definition at line 167 of file stylestack.cpp.

References m_nodeNames, m_stack, and searchAttribute().

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

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

Definition at line 181 of file stylestack.cpp.

References m_nodeNames, m_stack, and searchAttribute().

double StyleStack::fontSize (  )  const

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

Definition at line 147 of file stylestack.cpp.

References m_nodeNames, m_stack, OODPlug::parseUnit(), searchAttribute(), and value.

QString StyleStack::userStyleName (  )  const

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

Definition at line 201 of file stylestack.cpp.

References isUserStyle(), and m_stack.

void StyleStack::fillNodeNameList ( QStringList &  names,
const StyleStack::Mode  mode 
) [private]

Definition at line 214 of file stylestack.cpp.

References OODraw2x.

Referenced by setMode(), and StyleStack().

QDomElement StyleStack::searchAttribute ( const QDomElement &  element,
const QStringList &  names,
const QString &  name 
) const [private]

Definition at line 228 of file stylestack.cpp.

Referenced by attribute(), childNode(), fontSize(), hasAttribute(), and hasChildNode().

QDomElement StyleStack::searchAttribute ( const QDomElement &  element,
const QStringList &  names,
const QString &  name,
const QString &  fullName 
) const [private]

Definition at line 249 of file stylestack.cpp.


Member Data Documentation

QStringList StyleStack::m_nodeNames [private]

QStack<int> StyleStack::m_marks [private]

Definition at line 153 of file stylestack.h.

Referenced by restore(), and save().

QList<QDomElement> StyleStack::m_stack [private]


The documentation for this class was generated from the following files:
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.