X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Floadcanvas.cpp;h=3da37e9a9c24c95cc9636a528644061786d87b1f;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=56ae540ec8ada5c13f1d759c6e8ba3827f0f86fb;hpb=66bff9875e5cda32a5472a78f973254bc0963849;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index 56ae540..3da37e9 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -7,6 +7,7 @@ ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** Copyright (c) 2007, 2008 Chris Moore +** Copyright (c) 2009 Carlos A. Sosa Navarro ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -1075,7 +1076,7 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas) // when loading a version 0.1 canvas, modify constant angle // waypoints to that they are within 180 degrees of the previous // waypoint's value - if (type == ValueBase::TYPE_ANGLE) + if (type == ValueBase::TYPE_ANGLE) { if (canvas->get_version() == "0.1") { @@ -2216,3 +2217,85 @@ CanvasParser::parse_from_file_as(const String &file_,const String &as_,String &e } return Canvas::Handle(); } + +Canvas::Handle +CanvasParser::parse_as(xmlpp::Element* node,String &errors) +{ + ChangeLocale change_locale(LC_NUMERIC, "C"); + try + { + total_warnings_=0; + if(node) + { + Canvas::Handle canvas(parse_canvas(node,0,false,"")); + if (!canvas) return canvas; + + const ValueNodeList& value_node_list(canvas->value_node_list()); + + again: + ValueNodeList::const_iterator iter; + for(iter=value_node_list.begin();iter!=value_node_list.end();++iter) + { + ValueNode::Handle value_node(*iter); + if(value_node->is_exported() && value_node->get_id().find("Unnamed")==0) + { + canvas->remove_value_node(value_node); + goto again; + } + } + + return canvas; + } + } + catch(Exception::BadLinkName) { synfig::error("BadLinkName Thrown"); } + catch(Exception::BadType) { synfig::error("BadType Thrown"); } + catch(Exception::FileNotFound) { synfig::error("FileNotFound Thrown"); } + catch(Exception::IDNotFound) { synfig::error("IDNotFound Thrown"); } + catch(Exception::IDAlreadyExists) { synfig::error("IDAlreadyExists Thrown"); } + catch(xmlpp::internal_error x) + { + if (!strcmp(x.what(), "Couldn't create parsing context")) + throw runtime_error(String(" * ") + _("Can't open file") + " \"" + "\""); + throw; + } + catch(const std::exception& ex) + { + synfig::error("Standard Exception: "+String(ex.what())); + errors = ex.what(); + return Canvas::Handle(); + } + catch(const String& str) + { + cerr<