summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Rosch <launchpad@insaner.com>2014-03-12 18:34:51 +0000
committerinsaner <launchpad@insaner.com>2014-03-12 18:34:51 +0000
commit76be008fcda64acffe569af78f77a07b0d4ea593 (patch)
tree9b0d89072acc9c36b3c5ed41dd797e4df4c63bfb
parentUse NEAREST filter when transforming cache (diff)
downloadinkscape-76be008fcda64acffe569af78f77a07b0d4ea593.tar.gz
inkscape-76be008fcda64acffe569af78f77a07b0d4ea593.zip
incorrect gradient transform on copy&paste.. committing for mathog
Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13139)
-rw-r--r--src/document.cpp3
-rw-r--r--src/id-clash.cpp7
-rw-r--r--src/sp-gradient.cpp19
-rw-r--r--src/sp-gradient.h1
4 files changed, 26 insertions, 4 deletions
diff --git a/src/document.cpp b/src/document.cpp
index d71fd97df..4756110f6 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -1552,7 +1552,8 @@ void SPDocument::importDefs(SPDocument *source)
SPGradient *gr = SP_GRADIENT(src);
for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
if (trg && SP_IS_GRADIENT(trg) && src != trg) {
- if (gr->isEquivalent(SP_GRADIENT(trg))) {
+ if (gr->isEquivalent(SP_GRADIENT(trg)) &&
+ gr->isAligned(SP_GRADIENT(trg))) {
// Change object references to the existing equivalent gradient
change_def_references(src, trg);
duplicate = true;
diff --git a/src/id-clash.cpp b/src/id-clash.cpp
index 76b8e6ff8..f59b3b920 100644
--- a/src/id-clash.cpp
+++ b/src/id-clash.cpp
@@ -215,9 +215,10 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc,
SPObject *cd_obj = current_doc->getObjectById(id);
if (cd_obj && SP_IS_GRADIENT(cd_obj)) {
- SPGradient *cd_gr = SP_GRADIENT(cd_obj);
- if (cd_gr->isEquivalent(SP_GRADIENT(elem))) {
- fix_clashing_ids = false;
+ SPGradient *cd_gr = SP_GRADIENT(cd_obj);
+ if ( cd_gr->isEquivalent(SP_GRADIENT(elem)) &&
+ cd_gr->isAligned(SP_GRADIENT(elem))) {
+ fix_clashing_ids = false;
}
}
}
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
diff --git a/src/sp-gradient.h b/src/sp-gradient.h
index 46eb41cdb..1dfff22ee 100644
--- a/src/sp-gradient.h
+++ b/src/sp-gradient.h
@@ -147,6 +147,7 @@ public:
int getStopCount() const;
gboolean isEquivalent(SPGradient *b);
+ gboolean isAligned(SPGradient *b);
/** Mesh Gradients **************/