summaryrefslogtreecommitdiffstats
path: root/src/sp-object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp-object.cpp')
-rw-r--r--src/sp-object.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index be3a1ab9d..024fce85a 100644
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
@@ -406,9 +406,9 @@ void SPObject::requestOrphanCollection() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// do not remove style or script elements (Bug #276244)
- if (SP_IS_STYLE_ELEM(this)) {
+ if (dynamic_cast<SPStyleElem *>(this)) {
// leave it
- } else if (SP_IS_SCRIPT(this)) {
+ } else if (dynamic_cast<SPScript *>(this)) {
// leave it
} else if ((! prefs->getBool("/options/cleanupswatches/value", false)) && SP_IS_PAINT_SERVER(this) && static_cast<SPPaintServer*>(this)->isSwatch() ) {
@@ -460,6 +460,23 @@ void SPObject::deleteObject(bool propagate, bool propagate_descendants)
sp_object_unref(this, NULL);
}
+void SPObject::cropToObject(SPObject *except)
+{
+ std::vector<SPObject*> toDelete;
+ for ( SPObject *child = this->firstChild(); child; child = child->getNext() ) {
+ if (SP_IS_ITEM(child)) {
+ if (child->isAncestorOf(except)) {
+ child->cropToObject(except);
+ } else if(child != except) {
+ toDelete.push_back(child);
+ }
+ }
+ }
+ for (std::size_t i = 0; i < toDelete.size(); ++i) {
+ (toDelete[i])->deleteObject(true, true);
+ }
+}
+
void SPObject::attach(SPObject *object, SPObject *prev)
{
//g_return_if_fail(parent != NULL);
@@ -1389,12 +1406,12 @@ bool SPObject::setDesc(gchar const *desc, bool verbatim)
return setTitleOrDesc(desc, "svg:desc", verbatim);
}
-gchar * SPObject::getTitleOrDesc(gchar const *svg_tagname) const
+char * SPObject::getTitleOrDesc(gchar const *svg_tagname) const
{
- gchar *result = 0;
+ char *result = NULL;
SPObject *elem = findFirstChild(svg_tagname);
if ( elem ) {
- result = g_string_free(elem->textualContent(), FALSE);
+ result = elem->textualContent();
}
return result;
}
@@ -1476,7 +1493,7 @@ SPObject * SPObject::findFirstChild(gchar const *tagname) const
return NULL;
}
-GString * SPObject::textualContent() const
+char* SPObject::textualContent() const
{
GString* text = g_string_new("");
@@ -1485,15 +1502,15 @@ GString * SPObject::textualContent() const
Inkscape::XML::NodeType child_type = child->repr->type();
if (child_type == Inkscape::XML::ELEMENT_NODE) {
- GString * new_text = child->textualContent();
- g_string_append(text, new_text->str);
- g_string_free(new_text, TRUE);
+ char* new_string = child->textualContent();
+ g_string_append(text, new_string);
+ g_free(new_string);
}
else if (child_type == Inkscape::XML::TEXT_NODE) {
g_string_append(text, child->repr->content());
}
}
- return text;
+ return g_string_free(text, FALSE);
}
/*