lib Library API Documentation

KoGenStyle Class Reference

A generic style, i.e. More...

#include <koGenStyles.h>

Collaboration diagram for KoGenStyle:

Collaboration graph
[legend]
List of all members.

Public Types

enum  {
  STYLE_PAGELAYOUT = 0, STYLE_USER = 1, STYLE_AUTO = 2, STYLE_MASTER = 3,
  STYLE_LIST = 4, STYLE_AUTO_LIST = 5, STYLE_NUMERIC_DATE = 7, STYLE_NUMERIC_TIME = 8,
  STYLE_NUMERIC_FRACTION = 9, STYLE_NUMERIC_PERCENTAGE = 10, STYLE_NUMERIC_SCIENTIFIC = 11, STYLE_NUMERIC_CURRENCY = 12,
  STYLE_NUMERIC_TEXT = 13, STYLE_HATCH = 14, STYLE_GRAPHICAUTO = 15
}
enum  PropertyType {
  DefaultType = 0, TextType, ChildElement, ParagraphType,
  N_NumTypes
}

Public Member Functions

 KoGenStyle (int type=0, const char *familyName=0, const QString &parentName=QString::null)
int type () const
const char * familyName () const
QString parentName () const
void addProperty (const QString &propName, const QString &propValue, PropertyType type=DefaultType)
void addProperty (const QString &propName, const char *propValue, PropertyType type=DefaultType)
void addProperty (const QString &propName, int propValue, PropertyType type=DefaultType)
void addProperty (const QString &propName, bool propValue, PropertyType type=DefaultType)
void addPropertyPt (const QString &propName, double propValue, PropertyType type=DefaultType)
void addAttribute (const QString &attrName, const QString &attrValue)
void addAttribute (const QString &attrName, const char *attrValue)
void addAttribute (const QString &attrName, int attrValue)
void addAttribute (const QString &attrName, bool attrValue)
void addAttributePt (const QString &attrName, double attrValue)
void addChildElement (const QString &elementName, const QString &elementContents)
void addStyleMap (const QMap< QString, QString > &styleMap)
void writeStyle (KoXmlWriter *writer, KoGenStyles &styles, const char *elementName, const QString &name, const char *propertiesElementName, bool closeElement=true, bool drawElement=false) const
bool operator< (const KoGenStyle &other) const
bool operator== (const KoGenStyle &other) const

Friends

class KoGenStyles

Detailed Description

A generic style, i.e.

basically a collection of properties and a name. Instances of KoGenStyle can either be held in the KoGenStyles collection, or created (e.g. on the stack) and given to KoGenStyles::lookup.

Author:
David Faure <faure@kde.org>

Definition at line 163 of file koGenStyles.h.


Member Enumeration Documentation

anonymous enum
 

Possible values for the "type" argument of the KoGenStyle constructor.

Those values can be extended by applications (starting at number 20), it's for their own consumption anyway. (The reason for having the very common ones here, is to make it possible to use them from libkotext).

Definition at line 173 of file koGenStyles.h.

enum KoGenStyle::PropertyType
 

The types of properties.

Enumeration values:
DefaultType  DefaultType depends on family: e.g.

paragraph-properties if family=paragraph or on the type of style (e.g. page-layout -> page-layout-properties). (In fact that tag name is the one passed to writeStyle)

TextType  TextType is always text-properties.
ParagraphType  ParagraphType is always paragraph-properties.

Definition at line 218 of file koGenStyles.h.


Constructor & Destructor Documentation

KoGenStyle::KoGenStyle int  type = 0,
const char *  familyName = 0,
const QString parentName = QString::null
[inline, explicit]
 

Start the definition of a new style.

Its name will be set later by KoGenStyles::lookup(), but first you must define its properties and attributes.

Parameters:
type this is a hook for the application to categorize styles See the STYLE_* enum. Ignored when writing out the style.
familyName The value for style:family, e.g. text, paragraph, graphic etc. The family is for style:style elements only; number styles and list styles don't have one.
parentName If set, name of the parent style from which this one inherits.

Definition at line 202 of file koGenStyles.h.


Member Function Documentation

int KoGenStyle::type  )  const [inline]
 

Return the type of this style, as set in the constructor.

Definition at line 207 of file koGenStyles.h.

const char* KoGenStyle::familyName  )  const [inline]
 

Return the family name.

Definition at line 210 of file koGenStyles.h.

QString KoGenStyle::parentName  )  const [inline]
 

Return the name of style's parent, if set.

Definition at line 213 of file koGenStyles.h.

Referenced by KoGenStyles::lookup().

void KoGenStyle::addProperty const QString propName,
const QString propValue,
PropertyType  type = DefaultType
[inline]
 

Add a property to the style.

Definition at line 235 of file koGenStyles.h.

Referenced by KoTextFormat::save(), KoParagLayout::saveOasis(), and KoPageLayout::saveOasis().

void KoGenStyle::addProperty const QString propName,
const char *  propValue,
PropertyType  type = DefaultType
[inline]
 

Overloaded version of addProperty that takes a char*, usually for "...".

Definition at line 239 of file koGenStyles.h.

void KoGenStyle::addProperty const QString propName,
int  propValue,
PropertyType  type = DefaultType
[inline]
 

Overloaded version of addProperty that converts an int to a string.

Definition at line 243 of file koGenStyles.h.

void KoGenStyle::addProperty const QString propName,
bool  propValue,
PropertyType  type = DefaultType
[inline]
 

Overloaded version of addProperty that converts a bool to a string (false/true).

Definition at line 247 of file koGenStyles.h.

void KoGenStyle::addPropertyPt const QString propName,
double  propValue,
PropertyType  type = DefaultType
 

Add a property which represents a distance, measured in pt The number is written out with the highest possible precision (unlike QString::number and setNum, which default to 6 digits), and the unit name ("pt") is appended to it.

Definition at line 246 of file koGenStyles.cpp.

Referenced by KoTextFormat::save(), KoParagLayout::saveOasis(), and KoPageLayout::saveOasis().

void KoGenStyle::addAttribute const QString attrName,
const QString attrValue
[inline]
 

Add an attribute to the style The difference between property and attributes is a bit oasis-format-specific: attributes are for the style element itself, and properties are in the style:properties child element.

Definition at line 264 of file koGenStyles.h.

Referenced by KoParagStyle::saveStyle(), and writeStyle().

void KoGenStyle::addAttribute const QString attrName,
const char *  attrValue
[inline]
 

Overloaded version of addAttribute that takes a char*, usually for "...".

Definition at line 268 of file koGenStyles.h.

void KoGenStyle::addAttribute const QString attrName,
int  attrValue
[inline]
 

Overloaded version of addAttribute that converts an int to a string.

Definition at line 272 of file koGenStyles.h.

void KoGenStyle::addAttribute const QString attrName,
bool  attrValue
[inline]
 

Overloaded version of addAttribute that converts a bool to a string.

Definition at line 277 of file koGenStyles.h.

void KoGenStyle::addAttributePt const QString attrName,
double  attrValue
 

Add an attribute which represents a distance, measured in pt The number is written out with the highest possible precision (unlike QString::number and setNum, which default to 6 digits), and the unit name ("pt") is appended to it.

Definition at line 254 of file koGenStyles.cpp.

void KoGenStyle::addChildElement const QString elementName,
const QString elementContents
[inline]
 

Add a child element to the style properties.

What is meant here is that the contents of the QString will be written out literally. This means you should use KoXmlWriter to generate it:

 QBuffer buffer;
 buffer.open( IO_WriteOnly );
 KoXmlWriter elementWriter( &buffer );  // TODO pass indentation level
 elementWriter.startElement( "..." );
 ...
 elementWriter.endElement();
 QString elementContents = QString::fromUtf8( buffer.buffer(), buffer.buffer().size() );
 gs.addChildElement( "...", elementContents );

The value of elementName isn't used, except that it must be unique.

Definition at line 308 of file koGenStyles.h.

Referenced by KoParagLayout::saveOasis(), KoParagCounter::saveOasis(), and KoOasisStyles::saveOasisTextStyle().

void KoGenStyle::addStyleMap const QMap< QString, QString > &  styleMap  )  [inline]
 

Add a style:map to the style.

Parameters:
styleMap the attributes for the map, associated as (name,value).

Definition at line 316 of file koGenStyles.h.

void KoGenStyle::writeStyle KoXmlWriter writer,
KoGenStyles styles,
const char *  elementName,
const QString name,
const char *  propertiesElementName,
bool  closeElement = true,
bool  drawElement = false
const
 

Write the definition of this style to writer, using the OASIS format.

Parameters:
writer the KoXmlWriter in which elementName will be created and filled in
styles the styles collection, used to look up the parent style
elementName the name of the XML element, e.g. "style:style"
name must come from the collection
propertiesElementName the name of the XML element with the style properties, e.g. "style:text-properties". Can be 0 in special cases where there should be no such item, in which case the attributes and elements are added under the style itself.
closeElement set it to false to be able to add more child elements to the style element
drawElement set it to true to add "draw:name" (used for gradient/hatch style) otherwise add "style:name"

Definition at line 138 of file koGenStyles.cpp.

References addAttribute(), KoXmlWriter::addAttribute(), KoXmlWriter::addCompleteElement(), attribute(), DefaultType, KoXmlWriter::endElement(), m_maps, ParagraphType, printDebug(), property(), KoXmlWriter::startElement(), KoGenStyles::style(), and TextType.

bool KoGenStyle::operator< const KoGenStyle other  )  const
 

QMap requires a complete sorting order.

Another solution would have been a qdict and a key() here, a la KoTextFormat, but the key was difficult to generate. Solutions with only a hash value (not representative of the whole data) require us to write a hashtable by hand....

Definition at line 300 of file koGenStyles.cpp.

References m_attributes, m_maps, m_parentName, m_properties, and m_type.

bool KoGenStyle::operator== const KoGenStyle other  )  const
 

Not needed for QMap, but can still be useful.

Definition at line 326 of file koGenStyles.cpp.

References m_attributes, m_maps, m_parentName, m_properties, and m_type.


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:40:59 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003