24#include <KoGenStyles.h>
25#include <KoOasisLoadingContext.h>
26#include <KoOasisStyles.h>
42VFill::VFill(
const VColor &c )
49VFill::VFill(
const VFill& fill )
56VFill::save( TQDomElement& element )
const
58 TQDomElement me = element.ownerDocument().createElement(
"FILL" );
59 element.appendChild( me );
61 if( !( m_type == none ) )
69 m_gradient.save( me );
71 else if( m_type ==
patt )
79VFill::saveOasis( KoGenStyles &mainStyles, KoGenStyle &style )
const
83 style.addProperty(
"draw:fill",
"solid" );
84 style.addProperty(
"draw:fill-color", TQColor( m_color ).name() );
85 if( m_color.opacity() < 1 )
86 style.addProperty(
"draw:opacity", TQString(
"%1%" ).arg( m_color.opacity() * 100. ) );
88 else if( m_type ==
grad )
90 style.addProperty(
"draw:fill",
"gradient" );
91 TQString
grad = m_gradient.saveOasis( mainStyles );
92 style.addProperty(
"draw:fill-gradient-name",
grad );
93 if( m_color.opacity() < 1 )
94 style.addProperty(
"draw:opacity", TQString(
"%1%" ).arg( m_color.opacity() * 100. ) );
96 else if( m_type ==
patt )
97 style.addProperty(
"draw:fill",
"hatch" );
99 style.addProperty(
"draw:fill",
"none" );
103VFill::loadOasis(
const TQDomElement &, KoOasisLoadingContext &context,
VObject* parent )
105 KoStyleStack &stack = context.styleStack();
106 if( stack.hasAttributeNS( KoXmlNS::draw,
"fill" ) )
108 if( stack.attributeNS( KoXmlNS::draw,
"fill" ) ==
"solid" )
111 setColor( TQColor( stack.attributeNS( KoXmlNS::draw,
"fill-color" ) ) );
113 else if( stack.attributeNS( KoXmlNS::draw,
"fill" ) ==
"gradient" )
116 TQString style = stack.attributeNS( KoXmlNS::draw,
"fill-gradient-name" );
117 kdDebug()<<
" style gradient name :"<<style<<endl;
118 TQDomElement *
grad = context.oasisStyles().drawStyles()[ style ];
119 kdDebug()<<
" style gradient name :"<<
grad <<endl;
121 m_gradient.loadOasis( *
grad, stack, parent );
123 if( stack.hasAttributeNS( KoXmlNS::draw,
"opacity" ) )
124 m_color.setOpacity( stack.attributeNS( KoXmlNS::draw,
"opacity" ).remove(
'%' ).toFloat() / 100. );
129VFill::load(
const TQDomElement& element )
134 TQDomNodeList list = element.childNodes();
135 for( uint i = 0; i < list.count(); ++i )
137 if( list.item( i ).isElement() )
139 TQDomElement e = list.item( i ).toElement();
140 if( e.tagName() ==
"COLOR" )
145 if( e.tagName() ==
"GRADIENT" )
148 m_gradient.load( e );
150 else if( e.tagName() ==
"PATTERN" )
160VFill::operator=(
const VFill& fill )
165 m_type = fill.m_type;
166 m_color = fill.m_color;
167 m_gradient = fill.m_gradient;
168 m_pattern = fill.m_pattern;
175VFill::transform(
const TQWMatrix& m )
178 gradient().transform( m );
180 pattern().transform( m );
This class keeps track of color properties.
Manages the fill of shapes.
The base class for all karbon objects.