lib Library API Documentation

KoStyleStack Class Reference

This class implements a stack for the different styles of an object. More...

#include <koStyleStack.h>

Collaboration diagram for KoStyleStack:

Collaboration graph
[legend]
List of all members.

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

Definition at line 55 of file koStyleStack.h.


Constructor & Destructor Documentation

KoStyleStack::KoStyleStack  ) 
 

Create a OASIS style stack.

Definition at line 30 of file koStyleStack.cc.

References clear().

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

References clear().


Member Function Documentation

void KoStyleStack::clear  ) 
 

Clears the complete stack.

Definition at line 46 of file koStyleStack.cc.

Referenced by KoStyleStack().

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

void KoStyleStack::restore  ) 
 

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

Definition at line 62 of file koStyleStack.cc.

void KoStyleStack::pop  ) 
 

Removes the style on top of the stack.

Definition at line 75 of file koStyleStack.cc.

void KoStyleStack::push const QDomElement style  ) 
 

Pushes the new style onto the stack.

Definition at line 84 of file koStyleStack.cc.

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

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

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

References KoDom::namedItemNS().

Referenced by KoTextFormat::load().

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

References KoDom::namedItemNS().

Referenced by KoTextFormat::load().

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

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

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

References KoDom::namedItemNS().

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

References KoDom::namedItemNS().

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

References KoDom::namedItemNS(), and KoUnit::parseValue().

Referenced by KoTextFormat::load().

QString KoStyleStack::userStyleName  )  const
 

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

not an auto style

Definition at line 264 of file koStyleStack.cc.

QString KoStyleStack::userStyleDisplayName  )  const
 

Return the display name of the style specified by the user, i.e.

not an auto style

Definition at line 278 of file koStyleStack.cc.

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 291 of file koStyleStack.cc.

Referenced by KoTextFormat::load().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:41:23 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003