From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/object-set.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/object-set.cpp') diff --git a/src/object-set.cpp b/src/object-set.cpp index d282e7894..627544a21 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -16,6 +16,7 @@ #include "persp3d.h" #include "preferences.h" +namespace Inkscape { bool ObjectSet::add(SPObject* object) { g_return_val_if_fail(object != NULL, false); @@ -202,7 +203,7 @@ SPItem *ObjectSet::largestItem(CompareSize compare) { } SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { - std::vector const items = itemList(); + std::vector const items = const_cast(this)->items(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; @@ -226,10 +227,10 @@ SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { return ist; } -SPObjectRange ObjectSet::range() { +SPObjectRange ObjectSet::objects() { return SPObjectRange(container.get().begin(), container.get().end()); } -std::vector ObjectSet::itemList() { +std::vector ObjectSet::items() { std::vector tmp = std::vector(container.begin(), container.end()); std::vector result; std::remove_if(tmp.begin(), tmp.end(), [](SPObject* o){return !SP_IS_ITEM(o);}); @@ -237,6 +238,18 @@ std::vector ObjectSet::itemList() { return result; } +std::vector ObjectSet::xmlNodes() { + std::vector list = items(); + std::vector result; + std::transform(list.begin(), list.end(), std::back_inserter(result), [](SPItem* item) { return item->getRepr(); }); + return result; +} + +Inkscape::XML::Node *ObjectSet::singleRepr() { + SPObject *obj = single(); + return obj ? obj->getRepr() : nullptr; +} + void ObjectSet::set(SPObject *object) { _clear(); _add(object); @@ -273,7 +286,7 @@ Geom::OptRect ObjectSet::bounds(SPItem::BBoxType type) const Geom::OptRect ObjectSet::geometricBounds() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); Geom::OptRect bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { @@ -284,7 +297,7 @@ Geom::OptRect ObjectSet::geometricBounds() const Geom::OptRect ObjectSet::visualBounds() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); Geom::OptRect bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { @@ -305,7 +318,7 @@ Geom::OptRect ObjectSet::preferredBounds() const Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); if (items.empty()) return bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { @@ -319,7 +332,7 @@ Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional ObjectSet::center() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); if (!items.empty()) { SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -381,4 +394,6 @@ void ObjectSet::_remove_3D_boxes_recursively(SPObject *obj) { } _3dboxes.erase(b); } -} \ No newline at end of file +} + +} // namespace Inkscape -- cgit v1.2.3