lib

#include <KoGenStyles.h>

Public Types

enum  {
  STYLE_PAGELAYOUT = 0 , STYLE_USER = 1 , STYLE_AUTO = 2 , STYLE_MASTER = 3 ,
  STYLE_LIST = 4 , STYLE_AUTO_LIST = 5 , STYLE_NUMERIC_NUMBER = 6 , 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 , ParagraphType , GraphicType ,
  Reserved1 , Reserved2 , ChildElement , N_NumTypes
}

Public Member Functions

 KoGenStyle (int type=0, const char *familyName=0, const TQString &parentName=TQString())
void setAutoStyleInStylesDotXml (bool b)
bool autoStyleInStylesDotXml () const
void setDefaultStyle (bool b)
bool isDefaultStyle () const
int type () const
const char * familyName () const
TQString parentName () const
void addProperty (const TQString &propName, const TQString &propValue, PropertyType type=DefaultType)
void addProperty (const TQString &propName, const char *propValue, PropertyType type=DefaultType)
void addProperty (const TQString &propName, int propValue, PropertyType type=DefaultType)
void addProperty (const TQString &propName, bool propValue, PropertyType type=DefaultType)
void addPropertyPt (const TQString &propName, double propValue, PropertyType type=DefaultType)
void addAttribute (const TQString &attrName, const TQString &attrValue)
void addAttribute (const TQString &attrName, const char *attrValue)
void addAttribute (const TQString &attrName, int attrValue)
void addAttribute (const TQString &attrName, bool attrValue)
void addAttributePt (const TQString &attrName, double attrValue)
void addChildElement (const TQString &elementName, const TQString &elementContents)
void addStyleMap (const TQMap< TQString, TQString > &styleMap)
bool isEmpty () const
void writeStyle (KoXmlWriter *writer, KoGenStyles &styles, const char *elementName, const TQString &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.nosp@m.@kde.nosp@m..org

Definition at line 182 of file KoGenStyles.h.

Member Enumeration Documentation

◆ anonymous enum

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 192 of file KoGenStyles.h.

◆ PropertyType

The types of properties.

Simple styles only write one foo-properties tag, in which case they can just use DefaultType. However a given style might want to write several kinds of properties, in which case it would need to use other property types than the default one.

For instance this style:

<style:style style:family="chart">
<style:chart-properties .../>
<style:graphic-properties .../>
<style:text-properties .../>
</style:style>

would use DefaultType for chart-properties (and would pass "style:chart-properties" to writeStyle(), and would use GraphicType and TextType.

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

GraphicType 

GraphicType is always graphic-properties.

Definition at line 273 of file KoGenStyles.h.

Constructor & Destructor Documentation

◆ KoGenStyle()

KoGenStyle::KoGenStyle ( int type = 0,
const char * familyName = 0,
const TQString & parentName = TQString() )
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
typethis is a hook for the application to categorize styles See the STYLE_* enum. Ignored when writing out the style.
familyNameThe 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.
parentNameIf set, name of the parent style from which this one inherits.

Definition at line 175 of file KoGenStyles.cpp.

◆ ~KoGenStyle()

KoGenStyle::~KoGenStyle ( )

Definition at line 182 of file KoGenStyles.cpp.

Member Function Documentation

◆ addAttribute() [1/4]

void KoGenStyle::addAttribute ( const TQString & attrName,
bool attrValue )
inline

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

Definition at line 336 of file KoGenStyles.h.

◆ addAttribute() [2/4]

void KoGenStyle::addAttribute ( const TQString & attrName,
const char * attrValue )
inline

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

Definition at line 327 of file KoGenStyles.h.

◆ addAttribute() [3/4]

void KoGenStyle::addAttribute ( const TQString & attrName,
const TQString & 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 323 of file KoGenStyles.h.

◆ addAttribute() [4/4]

void KoGenStyle::addAttribute ( const TQString & attrName,
int attrValue )
inline

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

Definition at line 331 of file KoGenStyles.h.

◆ addAttributePt()

void KoGenStyle::addAttributePt ( const TQString & attrName,
double attrValue )

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

Definition at line 307 of file KoGenStyles.cpp.

◆ addChildElement()

void KoGenStyle::addChildElement ( const TQString & elementName,
const TQString & elementContents )
inline

Add a child element to the style properties.

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

TQBuffer buffer;
buffer.open( IO_WriteOnly );
KoXmlWriter elementWriter( &buffer ); // TODO pass indentation level
elementWriter.startElement( "..." );
...
elementWriter.endElement();
TQString elementContents = TQString::fromUtf8( buffer.buffer(), buffer.buffer().size() );
gs.addChildElement( "...", elementContents );
A class for writing out XML (to any TQIODevice), with a special attention on performance.
Definition KoXmlWriter.h:37

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

Definition at line 367 of file KoGenStyles.h.

◆ addProperty() [1/4]

void KoGenStyle::addProperty ( const TQString & propName,
bool propValue,
PropertyType type = DefaultType )
inline

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

Definition at line 306 of file KoGenStyles.h.

◆ addProperty() [2/4]

void KoGenStyle::addProperty ( const TQString & propName,
const char * propValue,
PropertyType type = DefaultType )
inline

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

Definition at line 298 of file KoGenStyles.h.

◆ addProperty() [3/4]

void KoGenStyle::addProperty ( const TQString & propName,
const TQString & propValue,
PropertyType type = DefaultType )
inline

Add a property to the style.

Definition at line 294 of file KoGenStyles.h.

◆ addProperty() [4/4]

void KoGenStyle::addProperty ( const TQString & propName,
int propValue,
PropertyType type = DefaultType )
inline

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

Definition at line 302 of file KoGenStyles.h.

◆ addPropertyPt()

void KoGenStyle::addPropertyPt ( const TQString & 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 TQString::number and setNum, which default to 6 digits), and the unit name ("pt") is appended to it.

Definition at line 299 of file KoGenStyles.cpp.

◆ addStyleMap()

void KoGenStyle::addStyleMap ( const TQMap< TQString, TQString > & styleMap)
inline

Add a style:map to the style.

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

Definition at line 375 of file KoGenStyles.h.

◆ autoStyleInStylesDotXml()

bool KoGenStyle::autoStyleInStylesDotXml ( ) const
inline
Returns
the value passed to setAutoStyleInStylesDotXml; false by default

Definition at line 235 of file KoGenStyles.h.

◆ familyName()

const char * KoGenStyle::familyName ( ) const
inline

Return the family name.

Definition at line 250 of file KoGenStyles.h.

◆ isDefaultStyle()

bool KoGenStyle::isDefaultStyle ( ) const
inline
Returns
the value passed to setDefaultStyle; false by default

Definition at line 244 of file KoGenStyles.h.

◆ isEmpty()

bool KoGenStyle::isEmpty ( ) const
inline
Returns
true if the style has no attributes, no properties, no style map etc. This can be used by applications which do not save all attributes unconditionally, but only those that differ from the parent. But note that lookup() can't find this out...

Definition at line 384 of file KoGenStyles.h.

◆ operator<()

bool KoGenStyle::operator< ( const KoGenStyle & other) const

TQMap 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 353 of file KoGenStyles.cpp.

◆ operator==()

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

Not needed for TQMap, but can still be useful.

Definition at line 380 of file KoGenStyles.cpp.

◆ parentName()

TQString KoGenStyle::parentName ( ) const
inline

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

Definition at line 253 of file KoGenStyles.h.

◆ setAutoStyleInStylesDotXml()

void KoGenStyle::setAutoStyleInStylesDotXml ( bool b)
inline

Definition at line 233 of file KoGenStyles.h.

◆ setDefaultStyle()

void KoGenStyle::setDefaultStyle ( bool b)
inline

Definition at line 242 of file KoGenStyles.h.

◆ type()

int KoGenStyle::type ( ) const
inline

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

Definition at line 247 of file KoGenStyles.h.

◆ writeStyle()

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

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

Parameters
writerthe KoXmlWriter in which elementName will be created and filled in
stylesthe styles collection, used to look up the parent style
elementNamethe name of the XML element, e.g. "style:style". Don't forget to pass style:default-style if isDefaultStyle().
namemust come from the collection. It will be ignored if isDefaultStyle() is true.
propertiesElementNamethe 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.
closeElementset it to false to be able to add more child elements to the style element
drawElementset it to true to add "draw:name" (used for gradient/hatch style) otherwise add "style:name"

Definition at line 201 of file KoGenStyles.cpp.

◆ KoGenStyles

friend class KoGenStyles
friend

Definition at line 460 of file KoGenStyles.h.


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