From 76be008fcda64acffe569af78f77a07b0d4ea593 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Wed, 12 Mar 2014 14:34:51 -0400 Subject: incorrect gradient transform on copy&paste.. committing for mathog Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13139) --- src/sp-gradient.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 04fb18cf3..e2ae98ec5 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -135,6 +135,25 @@ gboolean SPGradient::isEquivalent(SPGradient *that) return TRUE; } +/** + * return true if this gradient is "aligned" to that gradient. + * Aligned means that they have exactly the same transform. + * @param that - A gradient to compare this to + */ +gboolean SPGradient::isAligned(SPGradient *that) +{ + bool status = FALSE; + + while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function + if(this->gradientTransform_set != that->gradientTransform_set) { break; } + if(this->gradientTransform_set && + (this->gradientTransform != that->gradientTransform)) { break; } + status = TRUE; + break; + } + return status; +} + /* * Gradient -- cgit v1.2.3 From 5ece992a297ec8fb400a32f4c8dbb34c592236a8 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Thu, 13 Mar 2014 21:55:24 +0100 Subject: Fix gradient position on document import (bug #1283193) Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13145) --- src/sp-gradient.cpp | 83 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 20 deletions(-) (limited to 'src/sp-gradient.cpp') diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index e2ae98ec5..115cb754a 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -111,33 +111,45 @@ gboolean SPGradient::isEquivalent(SPGradient *that) { //TODO Make this work for mesh gradients - if (this->getStopCount() != that->getStopCount()) - return FALSE; - - if (this->hasStops() != that->hasStops()) - return FALSE; - - if (!this->getVector() || !that->getVector()) - return FALSE; + bool status = FALSE; + + while(1){ // not really a loop, used to avoid deep nesting or multiple exit points from function + if (this->getStopCount() != that->getStopCount()) { break; } + if (this->hasStops() != that->hasStops()) { break; } + if (!this->getVector() || !that->getVector()) { break; } + if ( (SP_IS_LINEARGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) || + (SP_IS_RADIALGRADIENT(this) && SP_IS_RADIALGRADIENT(that)) || + (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that))) { + /* OK! */ + } + else { break; } - SPStop *as = this->getVector()->getFirstStop(); - SPStop *bs = that->getVector()->getFirstStop(); + SPStop *as = this->getVector()->getFirstStop(); + SPStop *bs = that->getVector()->getFirstStop(); - while (as && bs) { - if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) || - as->offset != bs->offset) { - return FALSE; + bool effective = TRUE; + while (effective && (as && bs)) { + if (!as->getEffectiveColor().isClose(bs->getEffectiveColor(), 0.001) || + as->offset != bs->offset) { + effective = FALSE; + break; + } + else { + as = as->getNextStop(); + bs = bs->getNextStop(); + } } - as = as->getNextStop(); - bs = bs->getNextStop(); - } + if(!effective)break; - return TRUE; + status = TRUE; + break; + } + return status; } /** * return true if this gradient is "aligned" to that gradient. - * Aligned means that they have exactly the same transform. + * Aligned means that they have exactly the same coordinates and transform. * @param that - A gradient to compare this to */ gboolean SPGradient::isAligned(SPGradient *that) @@ -148,13 +160,44 @@ gboolean SPGradient::isAligned(SPGradient *that) if(this->gradientTransform_set != that->gradientTransform_set) { break; } if(this->gradientTransform_set && (this->gradientTransform != that->gradientTransform)) { break; } + if (SP_IS_LINEARGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) { + SPLinearGradient *sg=SP_LINEARGRADIENT(this); + SPLinearGradient *tg=SP_LINEARGRADIENT(that); + + if( !sg->x1._set || !tg->x1._set || // assume that if these are set so will be all the others + (sg->x1.computed != tg->x1.computed) || + (sg->y1.computed != tg->y1.computed) || + (sg->x2.computed != tg->x2.computed) || + (sg->y2.computed != tg->y2.computed) + ) { break; } + } else if (SP_IS_RADIALGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) { + SPRadialGradient *sg=SP_RADIALGRADIENT(this); + SPRadialGradient *tg=SP_RADIALGRADIENT(that); + if( !sg->cx._set || !tg->cx._set || // assume that if these are set so will be all the others + (sg->cx.computed != tg->cx.computed) || + (sg->cy.computed != tg->cy.computed) || + (sg->r.computed != tg->r.computed ) || + (sg->fx.computed != tg->fx.computed) || + (sg->fy.computed != tg->fy.computed) + ) { break; } + } else if (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that)) { + SPMeshGradient *sg=SP_MESHGRADIENT(this); + SPMeshGradient *tg=SP_MESHGRADIENT(that); + + if( !sg->x._set || !tg->x._set || + !sg->y._set || !tg->y._set || + (sg->x.computed != tg->x.computed) || + (sg->y.computed != tg->y.computed) + ) { break; } + } else { + break; + } status = TRUE; break; } return status; } - /* * Gradient */ -- cgit v1.2.3