diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-09-19 01:52:19 +0000 |
|---|---|---|
| committer | John Smith <john.smith7545@yahoo.com> | 2012-09-19 01:52:19 +0000 |
| commit | bf7c3e8d98b557cb64447804399797d93e1cedc0 (patch) | |
| tree | 80848f225cad4c163c32ce4d2ec963982558adba /src/document.cpp | |
| parent | Fix for 900602 : Enter key returns focus to canvas for Font family selector (diff) | |
| download | inkscape-bf7c3e8d98b557cb64447804399797d93e1cedc0.tar.gz inkscape-bf7c3e8d98b557cb64447804399797d93e1cedc0.zip | |
Fix for 643150 : Auto-palette swatches duplicated on copy and paste
(bzr r11677)
Diffstat (limited to '')
| -rw-r--r-- | src/document.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/document.cpp b/src/document.cpp index 9efd9d923..e28356969 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1453,10 +1453,33 @@ void SPDocument::importDefs(SPDocument *source) prevent_id_clashes(source, this); for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); - target_defs->appendChild(dup); - Inkscape::GC::release(dup); + + // Prevent duplicates of solid swatches by checking if equivalent swatch already exists + gboolean duplicate = false; + SPObject *src = source->getObjectByRepr(def); + if (src && SP_IS_GRADIENT(src)) { + SPGradient *gr = SP_GRADIENT(src); + if (gr->isSolid() || gr->getVector()->isSolid()) { + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if (trg && SP_IS_GRADIENT(trg) && src != trg) { + if (gr->isEquivalent(SP_GRADIENT(trg))) { + // Change object references to the existing equivalent gradient + change_def_references(src, trg); + duplicate = true; + break; + } + } + } + } + } + + if (!duplicate) { + Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); + target_defs->appendChild(dup); + Inkscape::GC::release(dup); + } } + } /* |
