24#include <tqvaluevector.h>
26#include <koffice_export.h>
59class KOFFICECORE_EXPORT KoGenStyles
77 DontForceNumbering = 1
97 TQString lookup( const KoGenStyle& style, const TQString& name = TQString(), int flags = NoFlag );
99 typedef TQMap<KoGenStyle, TQString> StyleMap;
104 const StyleMap& styles() const { return m_styleMap; }
119 TQValueList<NamedStyle> styles( int type, bool markedForStylesXml = false ) const;
124 const KoGenStyle* style( const TQString& name ) const;
133 KoGenStyle* styleForModification( const TQString& name );
147 void markStyleForStylesXml( const TQString& name );
155 TQString makeUniqueName( const TQString& base, int flags ) const;
163 typedef TQMap<TQString, bool> NameMap;
164 NameMap m_styleNames;
165 NameMap m_autoStylesInStylesDotXml;
168 typedef TQValueVector<NamedStyle> StyleArray;
169 StyleArray m_styleArray;
192 enum { STYLE_PAGELAYOUT = 0,
198 STYLE_NUMERIC_NUMBER = 6,
199 STYLE_NUMERIC_DATE = 7,
200 STYLE_NUMERIC_TIME = 8,
201 STYLE_NUMERIC_FRACTION = 9,
202 STYLE_NUMERIC_PERCENTAGE = 10,
203 STYLE_NUMERIC_SCIENTIFIC = 11,
204 STYLE_NUMERIC_CURRENCY = 12,
205 STYLE_NUMERIC_TEXT = 13,
207 STYLE_GRAPHICAUTO = 15};
233 void setAutoStyleInStylesDotXml( bool b ) { m_autoStyleInStylesDotXml = b; }
242 void setDefaultStyle( bool b ) { m_defaultStyle = b; }
247 int type() const { return m_type; }
250 const char* familyName() const { return m_familyName.data(); }
295 m_properties[ type].insert( propName, propValue );
299 m_properties[ type].insert( propName, TQString::fromUtf8( propValue ) );
303 m_properties[ type].insert( propName, TQString::number( propValue ) );
307 m_properties[ type].insert( propName, propValue ? "true" : "false" );
316 void addPropertyPt( const TQString& propName, double propValue, PropertyType type = DefaultType );
323 void addAttribute( const TQString& attrName, const TQString& attrValue ) {
324 m_attributes.insert( attrName, attrValue );
328 m_attributes.insert( attrName, TQString::fromUtf8( attrValue ) );
332 m_attributes.insert( attrName, TQString::number( attrValue ) );
337 m_attributes.insert( attrName, attrValue ? "true" : "false" );
346 void addAttributePt( const TQString& attrName, double attrValue );
367 void addChildElement( const TQString& elementName, const TQString& elementContents ) {
368 m_properties[ChildElement].insert( elementName, elementContents );
376 m_maps.append( styleMap );
385 if ( !m_attributes.isEmpty() || ! m_maps.isEmpty() )
387 for ( uint i = 0 ; i < N_NumTypes ; ++i )
388 if ( ! m_properties[i]. isEmpty() )
407 const char* propertiesElementName, bool closeElement = true, bool drawElement = false ) const;
416 bool operator<( const KoGenStyle &other ) const;
419 bool operator==( const KoGenStyle &other ) const;
422 TQString property( const TQString& propName, PropertyType type ) const {
423 TQMap<TQString, TQString>::const_iterator it = m_properties[type].find( propName );
424 if ( it != m_properties[type].end() )
429 TQString attribute( const TQString& propName ) const {
430 TQMap<TQString, TQString>::const_iterator it = m_attributes.find( propName );
431 if ( it != m_attributes.end() )
436 void writeStyleProperties( KoXmlWriter* writer, PropertyType i,
437 const char* elementName, const KoGenStyle* parentStyle ) const;
440 void printDebug() const;
447 TQCString m_familyName;
448 TQString m_parentName;
450 TQMap<TQString, TQString> m_properties[N_NumTypes];
451 TQMap<TQString, TQString> m_attributes;
452 typedef TQMap<TQString, TQString> StyleMap;
453 TQValueVector<StyleMap> m_maps;
455 bool m_autoStyleInStylesDotXml;
460 friend class KoGenStyles;
KoGenStyle(int type=0, const char *familyName=0, const TQString &parentName=TQString()) Start the definition of a new style.
void addChildElement(const TQString &elementName, const TQString &elementContents) Add a child element to the style properties.
void addProperty(const TQString &propName, int propValue, PropertyType type=DefaultType) Overloaded version of addProperty that converts an int to a string.
const char * familyName() const Return the family name.
void addStyleMap(const TQMap< TQString, TQString > &styleMap) Add a style:map to the style.
void addProperty(const TQString &propName, bool propValue, PropertyType type=DefaultType) Overloaded version of addProperty that converts a bool to a string (false/true).
void addAttribute(const TQString &attrName, int attrValue) Overloaded version of addAttribute that converts an int to a string.
void addAttribute(const TQString &attrName, const char *attrValue) Overloaded version of addAttribute that takes a char*, usually for "...".
PropertyType The types of properties.
@ DefaultType DefaultType depends on family: e.g.
@ GraphicType GraphicType is always graphic-properties.
@ TextType TextType is always text-properties.
@ ParagraphType ParagraphType is always paragraph-properties.
TQString parentName() const Return the name of style's parent, if set.
int type() const Return the type of this style, as set in the constructor.
bool isDefaultStyle() const
void addProperty(const TQString &propName, const TQString &propValue, PropertyType type=DefaultType) Add a property to the style.
void addAttribute(const TQString &attrName, bool attrValue) Overloaded version of addAttribute that converts a bool to a string.
void addProperty(const TQString &propName, const char *propValue, PropertyType type=DefaultType) Overloaded version of addProperty that takes a char*, usually for "...".
bool autoStyleInStylesDotXml() const
void addAttribute(const TQString &attrName, const TQString &attrValue) Add an attribute to the style The difference between property and attributes is a bit oasis-format-sp...
Repository of styles used during saving of OASIS/OOo file.
const StyleMap & styles() const Return the entire collection of styles Use this for saving the styles.
Flags Those are flags for the lookup() call.
A class for writing out XML (to any TQIODevice), with a special attention on performance.
|