summaryrefslogtreecommitdiffstats
path: root/src/document.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-24 23:26:11 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-24 23:26:11 +0000
commit7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5 (patch)
tree48cae26bf789b11d79f72efc16a6676f960eaaa6 /src/document.cpp
parentupdate to trunk (diff)
parent3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff)
downloadinkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.tar.gz
inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.zip
update to trunk
(bzr r12588.1.45)
Diffstat (limited to 'src/document.cpp')
-rw-r--r--src/document.cpp45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/document.cpp b/src/document.cpp
index 1c6bb76de..ebf5d312f 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -1266,7 +1266,7 @@ static bool overlaps(Geom::Rect const &area, Geom::Rect const &box)
return area.intersects(box);
}
-static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,
+static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,
bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false)
{
g_return_val_if_fail(SP_IS_GROUP(group), s);
@@ -1279,7 +1279,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey,
SPItem *child = SP_ITEM(o);
Geom::OptRect box = child->desktopVisualBounds();
if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
- s = g_slist_append(s, child);
+ s.push_back(child);
}
}
}
@@ -1306,7 +1306,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group)
return inGroup;
}
-SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive)
+SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive)
{
g_return_val_if_fail(group, NULL);
SPItem *bottomMost = 0;
@@ -1320,7 +1320,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro
Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey);
if (arenaitem && arenaitem->pick(p, delta, 1) != NULL
&& (take_insensitive || item->isVisibleAndUnlocked(dkey))) {
- if (g_slist_find((GSList *) list, item) != NULL) {
+ if (find(list.begin(),list.end(),item)!=list.end() ) {
bottomMost = item;
}
}
@@ -1422,11 +1422,11 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin
* Assumes box is normalized (and g_asserts it!)
*
*/
-GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const
+std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const
{
- g_return_val_if_fail(this->priv != NULL, NULL);
-
- return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within);
+ std::vector<SPItem*> x;
+ g_return_val_if_fail(this->priv != NULL, x);
+ return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within);
}
/*
@@ -1436,16 +1436,16 @@ GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) cons
*
*/
-GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const
+std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const
{
- g_return_val_if_fail(this->priv != NULL, NULL);
-
- return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps);
+ std::vector<SPItem*> x;
+ g_return_val_if_fail(this->priv != NULL, x);
+ return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps);
}
-GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
+std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
{
- GSList *items = NULL;
+ std::vector<SPItem*> items;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// When picking along the path, we don't want small objects close together
@@ -1454,11 +1454,11 @@ GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point
gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
prefs->setDouble("/options/cursortolerance/value", 0.25);
- for(unsigned int i = 0; i < points.size(); i++) {
+ for(int i = points.size()-1;i>=0; i--) {
SPItem *item = getItemAtPoint(key, points[i],
false, NULL);
- if (item && !g_slist_find(items, item))
- items = g_slist_prepend (items, item);
+ if (item && items.end()==find(items.begin(),items.end(), item))
+ items.push_back(item);
}
// and now we restore it back
@@ -1591,7 +1591,7 @@ static void vacuum_document_recursive(SPObject *obj)
unsigned int SPDocument::vacuumDocument()
{
unsigned int start = objects_in_document(this);
- unsigned int end = start;
+ unsigned int end;
unsigned int newend = start;
unsigned int iterations = 0;
@@ -1634,11 +1634,18 @@ void SPDocument::setModifiedSinceSave(bool modified) {
void SPDocument::importDefs(SPDocument *source)
{
Inkscape::XML::Node *root = source->getReprRoot();
- Inkscape::XML::Node *defs = sp_repr_lookup_name(root, "svg:defs", 1);
Inkscape::XML::Node *target_defs = this->getDefs()->getRepr();
+ std::vector<Inkscape::XML::Node const *> defsNodes = sp_repr_lookup_name_many(root, "svg:defs");
prevent_id_clashes(source, this);
+ for (std::vector<Inkscape::XML::Node const *>::iterator defs = defsNodes.begin(); defs != defsNodes.end(); ++defs) {
+ importDefsNode(source, const_cast<Inkscape::XML::Node *>(*defs), target_defs);
+ }
+}
+
+void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, Inkscape::XML::Node *target_defs)
+{
int stagger=0;
/* Note, "clipboard" throughout the comments means "the document that is either the clipboard