X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Floadcanvas.cpp;h=6edf4e58c7fb408e17082836e7ffbf3d50cd753f;hb=c330cbb315df4b609c494e324b9b248a4e5f3598;hp=8f1fd68b0a334f4e9e3ce73ded729a906378b0db;hpb=e3acc0b267b14fda5db3c7bbb2f218b993ef84b3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index 8f1fd68..6edf4e5 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -1,20 +1,21 @@ -/* === S I N F G =========================================================== */ +/* === S Y N F I G ========================================================= */ /*! \file loadcanvas.cpp ** \brief writeme ** ** $Id: loadcanvas.cpp,v 1.3 2005/01/04 23:40:44 darco Exp $ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -69,15 +70,15 @@ /* === U S I N G =========================================================== */ using namespace std; -using namespace sinfg; +using namespace synfig; using namespace etl; /* class test_class { static int bleh; public: - test_class() { assert(!bleh); bleh++; sinfg::info("test_class: initi: %d",bleh); } - ~test_class() { assert(bleh); sinfg::info("test_class: uninit: %d",bleh); bleh--; } + test_class() { assert(!bleh); bleh++; synfig::info("test_class: initi: %d",bleh); } + ~test_class() { assert(bleh); synfig::info("test_class: uninit: %d",bleh); bleh--; } }; int test_class::bleh(0); @@ -92,7 +93,7 @@ inline bool is_whitespace(char x) { return ((x)=='\n' || (x)=='\t' || (x)==' '); static std::map* open_canvas_map_(0); -std::map >& sinfg::get_open_canvas_map() +std::map >& synfig::get_open_canvas_map() { if(!open_canvas_map_) open_canvas_map_=new std::map; @@ -103,7 +104,7 @@ static void _remove_from_open_canvas_map(Canvas *x) { get_open_canvas_map().eras static void _canvas_file_name_changed(Canvas *x) { - std::map >::iterator iter; + std::map >::iterator iter; for(iter=get_open_canvas_map().begin();iter!=get_open_canvas_map().end();++iter) if(iter->second==x) @@ -117,7 +118,7 @@ static void _canvas_file_name_changed(Canvas *x) } Canvas::Handle -sinfg::open_canvas(const String &filename) +synfig::open_canvas(const String &filename) { CanvasParser parser; @@ -132,7 +133,7 @@ sinfg::open_canvas(const String &filename) } Canvas::Handle -sinfg::open_canvas_as(const String &filename,const String &as) +synfig::open_canvas_as(const String &filename,const String &as) { CanvasParser parser; @@ -147,7 +148,7 @@ sinfg::open_canvas_as(const String &filename,const String &as) } Canvas::Handle -sinfg::string_to_canvas(const String &data) +synfig::string_to_canvas(const String &data) { CanvasParser parser; @@ -179,7 +180,7 @@ void CanvasParser::warning(xmlpp::Node *element, const String &text) { string str=strprintf("%s:<%s>:%d: warning: ",filename.c_str(),element->get_name().c_str(),element->get_line())+text; - //sinfg::warning(str); + //synfig::warning(str); cerr<=max_warnings_) @@ -194,7 +195,7 @@ CanvasParser::error(xmlpp::Node *element, const String &text) if(!allow_errors_) throw runtime_error(str); cerr<"); return Vector(); } - xmlpp::TextNode *text=dynamic_cast(child->get_children().front()); - if(!text) - { - error(element,"I need a number, not an element!"); - return Vector(); - } - vect[0]=atof(text->get_content().c_str()); + vect[0]=atof(child->get_child_text()->get_content().c_str()); } else if(child->get_name()=="y") @@ -332,13 +327,7 @@ CanvasParser::parse_vector(xmlpp::Element *element,Canvas::Handle canvas) error(element, "Undefined value in "); return Vector(); } - xmlpp::TextNode *text=dynamic_cast(child->get_children().front()); - if(!text) - { - error(element,"I need a number, not an element!"); - return Vector(); - } - vect[1]=atof(text->get_content().c_str()); + vect[1]=atof(child->get_child_text()->get_content().c_str()); } else error_unexpected_element(child,child->get_name()); @@ -412,7 +401,7 @@ CanvasParser::parse_color(xmlpp::Element *element,Canvas::Handle canvas) return color; } -sinfg::String +synfig::String CanvasParser::parse_string(xmlpp::Element *element,Canvas::Handle canvas) { assert(element->get_name()=="string"); @@ -420,13 +409,13 @@ CanvasParser::parse_string(xmlpp::Element *element,Canvas::Handle canvas) if(element->get_children().empty()) { warning(element, "Undefined value in "); - return sinfg::String(); + return synfig::String(); } if(element->get_child_text()->get_content().empty()) { warning(element, "Content element of appears to be empty"); - return sinfg::String(); + return synfig::String(); } return element->get_child_text()->get_content(); @@ -975,22 +964,22 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas) if(child->get_attribute("tension")) { - sinfg::String str(child->get_attribute("tension")->get_value()); + synfig::String str(child->get_attribute("tension")->get_value()); waypoint->set_tension(atof(str.c_str())); } if(child->get_attribute("temporal-tension")) { - sinfg::String str(child->get_attribute("temporal-tension")->get_value()); + synfig::String str(child->get_attribute("temporal-tension")->get_value()); waypoint->set_time_tension(atof(str.c_str())); } if(child->get_attribute("continuity")) { - sinfg::String str(child->get_attribute("continuity")->get_value()); + synfig::String str(child->get_attribute("continuity")->get_value()); waypoint->set_continuity(atof(str.c_str())); } if(child->get_attribute("bias")) { - sinfg::String str(child->get_attribute("bias")->get_value()); + synfig::String str(child->get_attribute("bias")->get_value()); waypoint->set_bias(atof(str.c_str())); } @@ -1581,8 +1570,8 @@ CanvasParser::parse_dynamic_list(xmlpp::Element *element,Canvas::Handle canvas) // Parse begin/end waypoints { - typedef sinfg::ValueNode_DynamicList::ListEntry::Activepoint Activepoint; - typedef sinfg::ValueNode_DynamicList::ListEntry::ActivepointList ActivepointList; + typedef synfig::ValueNode_DynamicList::ListEntry::Activepoint Activepoint; + typedef synfig::ValueNode_DynamicList::ListEntry::ActivepointList ActivepointList; String begin_sequence; String end_sequence; @@ -1621,7 +1610,7 @@ CanvasParser::parse_dynamic_list(xmlpp::Element *element,Canvas::Handle canvas) int space=timecode.find_first_of(' '); priority=atoi(String(timecode,1,space-1).c_str()); timecode=String(timecode.begin()+space+1,timecode.end()); - //sinfg::info("priority: %d timecode: %s",priority,timecode.c_str()); + //synfig::info("priority: %d timecode: %s",priority,timecode.c_str()); } timing_info.push_back( @@ -1657,7 +1646,7 @@ CanvasParser::parse_dynamic_list(xmlpp::Element *element,Canvas::Handle canvas) int space=timecode.find_first_of(' '); priority=atoi(String(timecode,1,space-1).c_str()); timecode=String(timecode.begin()+space+1,timecode.end()); - //sinfg::info("priority: %d timecode: %s",priority,timecode.c_str()); + //synfig::info("priority: %d timecode: %s",priority,timecode.c_str()); } timing_info.push_back( @@ -2254,11 +2243,15 @@ CanvasParser::parse_from_file(const String &file) } Canvas::Handle -CanvasParser::parse_from_file_as(const String &file,const String &as) +CanvasParser::parse_from_file_as(const String &file_,const String &as_) { CHECK_EXPIRE_TIME(); try { + ChangeLocale change_locale(LC_NUMERIC, "C"); + String file(unix_to_local_path(file_)); + String as(unix_to_local_path(as_)); + if(get_open_canvas_map().count(etl::absolute_path(as))) return get_open_canvas_map()[etl::absolute_path(as)]; @@ -2291,20 +2284,20 @@ CanvasParser::parse_from_file_as(const String &file,const String &as) return canvas; } } - catch(Exception::BadLinkName) { sinfg::error("BadLinkName Thrown"); } - catch(Exception::BadType) { sinfg::error("BadType Thrown"); } - catch(Exception::FileNotFound) { sinfg::error("FileNotFound Thrown"); } - catch(Exception::IDNotFound) { sinfg::error("IDNotFound Thrown"); } - catch(Exception::IDAlreadyExists) { sinfg::error("IDAlreadyExists Thrown"); } + 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(const std::exception& ex) { - sinfg::error("Standard Exception: "+String(ex.what())); + synfig::error("Standard Exception: "+String(ex.what())); return Canvas::Handle(); } catch(const String& str) { cerr<"); total_warnings_=0; xmlpp::DomParser parser; @@ -2344,20 +2338,20 @@ CanvasParser::parse_from_string(const String &data) return canvas; } } - catch(Exception::BadLinkName) { sinfg::error("BadLinkName Thrown"); } - catch(Exception::BadType) { sinfg::error("BadType Thrown"); } - catch(Exception::FileNotFound) { sinfg::error("FileNotFound Thrown"); } - catch(Exception::IDNotFound) { sinfg::error("IDNotFound Thrown"); } - catch(Exception::IDAlreadyExists) { sinfg::error("IDAlreadyExists Thrown"); } + 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(const std::exception& ex) { - sinfg::error("Standard Exception: "+String(ex.what())); + synfig::error("Standard Exception: "+String(ex.what())); return Canvas::Handle(); } catch(const String& str) { cerr<