[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/lib/kofficecore
From: David Faure <faure () kde ! org>
Date: 2006-03-02 15:49:29
Message-ID: 1141314569.521490.6552.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 515078 by dfaure:
KChart will need styles with chart-properties + graphic-properties + text-properties
(for the title, for instance)
M +19 -20 KoGenStyles.cpp
M +24 -2 KoGenStyles.h
--- trunk/koffice/lib/kofficecore/KoGenStyles.cpp #515077:515078
@@ -157,6 +157,21 @@
{
}
+void KoGenStyle::writeStyleProperties( KoXmlWriter* writer, PropertyType i,
+ const char* elementName, const KoGenStyle* \
parentStyle ) const +{
+ if ( !m_properties[i].isEmpty() ) {
+ writer->startElement( elementName );
+ QMap<QString, QString>::const_iterator it = m_properties[i].begin();
+ const QMap<QString, QString>::const_iterator end = m_properties[i].end();
+ for ( ; it != end; ++it ) {
+ if ( !parentStyle || parentStyle->property( it.key(), i ) != it.data() )
+ writer->addAttribute( it.key().utf8(), it.data().utf8() );
+ }
+ writer->endElement();
+ }
+}
+
void KoGenStyle::writeStyle( KoXmlWriter* writer, KoGenStyles& styles, const char* \
elementName, const QString& name, const char* propertiesElementName, bool \
closeElement, bool drawElement ) const {
//kdDebug(30003) << "writing out style " << name << " " << \
m_attributes["style:display-name"] << " " << m_familyName << endl; @@ -232,26 +247,10 \
@@ if ( createPropertiesTag )
writer->endElement();
}
- i = KoGenStyle::TextType;
- if ( !m_properties[i].isEmpty() ) {
- writer->startElement( "style:text-properties" );
- it = m_properties[i].begin();
- for ( ; it != m_properties[i].end(); ++it ) {
- if ( !parentStyle || parentStyle->property( it.key(), i ) != it.data() )
- writer->addAttribute( it.key().utf8(), it.data().utf8() );
- }
- writer->endElement();
- }
- i = KoGenStyle::ParagraphType;
- if ( !m_properties[i].isEmpty() ) {
- writer->startElement( "style:paragraph-properties" );
- it = m_properties[i].begin();
- for ( ; it != m_properties[i].end(); ++it ) {
- if ( !parentStyle || parentStyle->property( it.key(), i ) != it.data() )
- writer->addAttribute( it.key().utf8(), it.data().utf8() );
- }
- writer->endElement();
- }
+ writeStyleProperties( writer, KoGenStyle::GraphicType, \
"style:graphic-properties", parentStyle ); + writeStyleProperties( writer, \
KoGenStyle::TextType, "style:text-properties", parentStyle ); + \
writeStyleProperties( writer, KoGenStyle::ParagraphType, \
"style:paragraph-properties", parentStyle ); +
// And now the style maps
for ( uint i = 0; i < m_maps.count(); ++i ) {
bool writeit = true;
--- trunk/koffice/lib/kofficecore/KoGenStyles.h #515077:515078
@@ -249,7 +249,22 @@
QString parentName() const { return m_parentName; }
/**
- * @brief The types of properties.
+ * @brief 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:
+ * @code
+ * <style:style style:family="chart">
+ * <style:chart-properties .../>
+ * <style:graphic-properties .../>
+ * <style:text-properties .../>
+ * </style:style>
+ * @endcode
+ * would use DefaultType for chart-properties (and would pass \
"style:chart-properties" to writeStyle(), + * and would use GraphicType and \
TextType.
*/
enum PropertyType
{
@@ -263,8 +278,12 @@
TextType,
/// ParagraphType is always paragraph-properties.
ParagraphType,
+ /// GraphicType is always graphic-properties.
+ GraphicType,
+ Reserved1, ///< @internal for binary compatible extensions
+ Reserved2, ///< @internal for binary compatible extensions
ChildElement, ///< @internal
- N_NumTypes ///< @internal
+ N_NumTypes ///< @internal - warning, adding items here affects binary \
compatibility (size of KoGenStyle) };
/// Add a property to the style
@@ -410,6 +429,9 @@
return QString::null;
}
+ void writeStyleProperties( KoXmlWriter* writer, PropertyType i,
+ const char* elementName, const KoGenStyle* \
parentStyle ) const; +
#ifndef NDEBUG
void printDebug() const;
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic