From 370a3f5cc9e39352a081e5d5dd8c43676547a6e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:45:44 +1000 Subject: code cleanup: add own includes to cpp files or make the functions static if they are not used elsewhere. (bzr r11735) --- src/document.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e28356969..9d8291db0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1107,7 +1107,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, /** Returns true if an item is among the descendants of group (recursively). */ -bool item_is_in_group(SPItem *item, SPGroup *group) +static bool item_is_in_group(SPItem *item, SPGroup *group) { bool inGroup = false; for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) { @@ -1158,7 +1158,7 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ -SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) +static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { SPItem *seen = NULL; SPItem *newseen = NULL; @@ -1203,7 +1203,7 @@ SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const Returns the topmost non-layer group from the descendants of group which is at point p, or NULL if none. Recurses into layers but not into groups. */ -SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) +static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) { SPItem *seen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1374,7 +1374,7 @@ sp_document_resource_list_free(gpointer /*key*/, gpointer value, gpointer /*data return TRUE; } -unsigned int count_objects_recursive(SPObject *obj, unsigned int count) +static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself @@ -1385,12 +1385,12 @@ unsigned int count_objects_recursive(SPObject *obj, unsigned int count) return count; } -unsigned int objects_in_document(SPDocument *document) +static unsigned int objects_in_document(SPDocument *document) { return count_objects_recursive(document->getRoot(), 0); } -void vacuum_document_recursive(SPObject *obj) +static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) { -- cgit v1.2.3 From f304ab600788b02cb02a4413f68f466e35cf1539 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 11 Oct 2012 19:54:14 +0200 Subject: Add symbols dialog. See: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog (bzr r11782) --- src/document.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 9d8291db0..172037518 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -7,10 +7,12 @@ * bulia byak * Jon A. Cruz * Abhishek Sharma + * Tavmjong Bah * * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. + * Copyright (C) 2012 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -59,6 +61,7 @@ #include "sp-item-group.h" #include "sp-namedview.h" #include "sp-object-repr.h" +#include "sp-symbol.h" #include "transf_mat_3x4.h" #include "unit-constants.h" #include "xml/repr.h" @@ -1454,9 +1457,10 @@ void SPDocument::importDefs(SPDocument *source) for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - // Prevent duplicates of solid swatches by checking if equivalent swatch already exists gboolean duplicate = false; SPObject *src = source->getObjectByRepr(def); + + // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *gr = SP_GRADIENT(src); if (gr->isSolid() || gr->getVector()->isSolid()) { @@ -1473,6 +1477,35 @@ void SPDocument::importDefs(SPDocument *source) } } + // Prevent duplication of symbols... could be more clever. + // The tag "_inkscape_duplicate" is added to "id" by ClipboardManagerImpl::copySymbol(). + // We assume that symbols are in defs section (not required by SVG spec). + if (src && SP_IS_SYMBOL(src)) { + + Glib::ustring id = src->getRepr()->attribute("id"); + size_t pos = id.find( "_inkscape_duplicate" ); + if( pos != Glib::ustring::npos ) { + + // This is our symbol, now get rid of tag + id.erase( pos ); + + // Check that it really is a duplicate + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if( trg && SP_IS_SYMBOL(trg) && src != trg ) { + std::string id2 = trg->getRepr()->attribute("id"); + + if( !id.compare( id2 ) ) { + duplicate = true; + break; + } + } + } + if ( !duplicate ) { + src->getRepr()->setAttribute("id", id.c_str() ); + } + } + } + if (!duplicate) { Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); target_defs->appendChild(dup); -- cgit v1.2.3