Commit 2205ad22 authored by Jan Hambrecht's avatar Jan Hambrecht

implemented basic gradient loading and saving (linear and radial gradients for now)


svn path=/trunk/koffice/; revision=690059
parent 9e357fd1
......@@ -630,24 +630,9 @@ QString KoShape::style( KoShapeSavingContext &context ) const
case Qt::NoBrush:
style.addProperty( "draw:fill","none" );
break;
case Qt::SolidPattern:
case Qt::Dense1Pattern:
case Qt::Dense2Pattern:
case Qt::Dense3Pattern:
case Qt::Dense4Pattern:
case Qt::Dense5Pattern:
case Qt::Dense6Pattern:
case Qt::Dense7Pattern:
case Qt::HorPattern:
case Qt::BDiagPattern:
case Qt::VerPattern:
case Qt::FDiagPattern:
case Qt::CrossPattern:
case Qt::DiagCrossPattern:
default:
KoOasisStyles::saveOasisFillStyle( style, context.mainStyles(), bg );
break;
default: // TODO all the other ones.
break;
}
if ( context.isSet( KoShapeSavingContext::AutoStyleInStyleXml ) ) {
......@@ -659,6 +644,18 @@ QString KoShape::style( KoShapeSavingContext &context ) const
bool KoShape::loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingContext &context, int attributes )
{
if ( attributes & OdfSize ) {
QPointF pos;
pos.setX( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "x", QString() ) ) );
pos.setY( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "y", QString() ) ) );
setPosition( pos );
QSizeF size;
size.setWidth( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "width", QString() ) ) );
size.setHeight( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "height", QString() ) ) );
resize( size );
}
if ( attributes & OdfMandatories ) {
if ( element.hasAttributeNS( KoXmlNS::draw, "layer" ) ) {
KoShapeLayer * layer = context.layer( element.attributeNS( KoXmlNS::draw, "layer" ) );
......@@ -685,18 +682,6 @@ bool KoShape::loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingCon
setBorder( loadOdfStroke( element, context ) );
}
if ( attributes & OdfSize ) {
QPointF pos;
pos.setX( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "x", QString() ) ) );
pos.setY( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "y", QString() ) ) );
setPosition( pos );
QSizeF size;
size.setWidth( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "width", QString() ) ) );
size.setHeight( KoUnit::parseValue( element.attributeNS( KoXmlNS::svg, "height", QString() ) ) );
resize( size );
}
if( attributes & OdfTransformation )
{
QString transform = element.attributeNS( KoXmlNS::draw, "transform", QString() );
......@@ -730,6 +715,8 @@ QBrush KoShape::loadOdfFill( const KoXmlElement & element, KoShapeLoadingContext
if ( fill == "solid" || fill == "hatch" )
return KoOasisStyles::loadOasisFillStyle( styleStack, fill, context.koLoadingContext().oasisStyles() );
else if( fill == "gradient" )
return KoOasisStyles::loadOasisGradientStyle( styleStack, context.koLoadingContext().oasisStyles(), size() );
return QBrush();
}
......
......@@ -62,8 +62,11 @@ public:
StyleHatch = 14,
StyleGraphicAuto = 15,
StylePresentationAuto = 16,
StyleStrokeDash = 17,
StyleFirstCustom = 2500 };
StyleStrokeDash = 17, ///< draw:stroke-dash as in 14.14.7 odf spec
StyleGradient = 18, ///< draw:gradient as in 14.14.1 odf spec
StyleGradientLinear = 19, ///< linear svg:gradient as in 14.14.2 odf spec
StyleGradientRadial = 20, ///< radial svg:gradient as in 14.14.2 odf spec
StyleFirstCustom = 2500 }; ///< the first style for applications to use
/**
* Start the definition of a new style. Its name will be set later by KoGenStyles::lookup(),
......
This diff is collapsed.
......@@ -149,6 +149,11 @@ public:
static void saveOasisFillStyle( KoGenStyle &styleFill, KoGenStyles& mainStyles, const QBrush & brush );
static QString saveOasisHatchStyle( KoGenStyles& mainStyles, const QBrush &brush );
/// Saves gradient style of brush into mainStyles and returns the styles name
static QString saveOasisGradientStyle( KoGenStyles &mainStyles, const QBrush &brush );
/// Loads gradient style from style stack and oasisStyles adapted to the given size and returns a brush
static QBrush loadOasisGradientStyle( const KoStyleStack &styleStack, const KoOasisStyles & oasisStyles, const QSizeF &size );
static QBrush loadOasisFillStyle( const KoStyleStack &styleStack, const QString & fill, const KoOasisStyles & oasisStyles );
static QPen loadOasisStrokeStyle( const KoStyleStack &styleStack, const QString & stroke, const KoOasisStyles & oasisStyles );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment