~moduli16/inkscape/recolor

« back to all changes in this revision

Viewing changes to src/document.cpp

  • Committer: tavmjong-free
  • Date: 2012-10-11 17:54:14 UTC
  • Revision ID: tavmjong@free.fr-20121011175414-j1i7huls4h70n91n
Add symbols dialog. See: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *   bulia byak <buliabyak@users.sf.net>
8
8
 *   Jon A. Cruz <jon@joncruz.org>
9
9
 *   Abhishek Sharma
 
10
 *   Tavmjong Bah <tavmjong@free.fr>
10
11
 *
11
12
 * Copyright (C) 2004-2005 MenTaLguY
12
13
 * Copyright (C) 1999-2002 Lauris Kaplinski
13
14
 * Copyright (C) 2000-2001 Ximian, Inc.
 
15
 * Copyright (C) 2012 Tavmjong Bah
14
16
 *
15
17
 * Released under GNU GPL, read the file 'COPYING' for more information
16
18
 */
59
61
#include "sp-item-group.h"
60
62
#include "sp-namedview.h"
61
63
#include "sp-object-repr.h"
 
64
#include "sp-symbol.h"
62
65
#include "transf_mat_3x4.h"
63
66
#include "unit-constants.h"
64
67
#include "xml/repr.h"
1454
1457
 
1455
1458
    for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) {
1456
1459
 
1457
 
        // Prevent duplicates of solid swatches by checking if equivalent swatch already exists
1458
1460
        gboolean duplicate = false;
1459
1461
        SPObject *src = source->getObjectByRepr(def);
 
1462
 
 
1463
        // Prevent duplicates of solid swatches by checking if equivalent swatch already exists
1460
1464
        if (src && SP_IS_GRADIENT(src)) {
1461
1465
            SPGradient *gr = SP_GRADIENT(src);
1462
1466
            if (gr->isSolid() || gr->getVector()->isSolid()) {
1473
1477
            }
1474
1478
        }
1475
1479
 
 
1480
        // Prevent duplication of symbols... could be more clever.
 
1481
        // The tag "_inkscape_duplicate" is added to "id" by ClipboardManagerImpl::copySymbol(). 
 
1482
        // We assume that symbols are in defs section (not required by SVG spec).
 
1483
        if (src && SP_IS_SYMBOL(src)) {
 
1484
 
 
1485
            Glib::ustring id = src->getRepr()->attribute("id");
 
1486
            size_t pos = id.find( "_inkscape_duplicate" );
 
1487
            if( pos != Glib::ustring::npos ) {
 
1488
 
 
1489
                // This is our symbol, now get rid of tag
 
1490
                id.erase( pos ); 
 
1491
 
 
1492
                // Check that it really is a duplicate
 
1493
                for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) {
 
1494
                    if( trg && SP_IS_SYMBOL(trg) && src != trg ) { 
 
1495
                        std::string id2 = trg->getRepr()->attribute("id");
 
1496
 
 
1497
                        if( !id.compare( id2 ) ) {
 
1498
                            duplicate = true;
 
1499
                            break;
 
1500
                        }
 
1501
                    }
 
1502
                }
 
1503
                if ( !duplicate ) {
 
1504
                    src->getRepr()->setAttribute("id", id.c_str() );
 
1505
                }
 
1506
            }
 
1507
        }
 
1508
 
1476
1509
        if (!duplicate) {
1477
1510
            Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc());
1478
1511
            target_defs->appendChild(dup);