From: Angus Leeming Date: Wed, 10 Dec 2003 21:32:05 +0000 (+0000) Subject: Use the new lyxlex interface in InsetERT. X-Git-Tag: 1.6.10~15667 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d3990cdad5ca8f46325bdbe807d183ff77987fb5;p=features.git Use the new lyxlex interface in InsetERT. Ensure that InetExternalParams has a default template (RasterImage). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8227 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index ada3f05a67..706bfe102b 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2003-12-10 Angus Leeming + + * insetert.C (string2params): clean-up using the new lyxlex interface. + + * insetexternal.C: ensure that InsetExternalParams has a default + template, 'RasterImage'. + 2003-12-10 Angus Leeming * insetnote.[Ch]: change the storage type of InsetNoteParams::type diff --git a/src/insets/insetert.C b/src/insets/insetert.C index eb5a7fd22c..1fe2feb33c 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -29,18 +29,18 @@ #include "frontends/Alert.h" #include "frontends/LyXView.h" -#include "support/tostr.h" +#include "support/std_sstream.h" using lyx::pos_type; -using lyx::support::split; -using lyx::support::strToInt; - using std::endl; using std::min; -using std::string; + using std::auto_ptr; +using std::istringstream; using std::ostream; +using std::ostringstream; +using std::string; void InsetERT::init() @@ -479,22 +479,33 @@ string const InsetERTMailer::inset2string(Buffer const &) const void InsetERTMailer::string2params(string const & in, - InsetCollapsable::InsetCollapsable::CollapseStatus & status) + InsetCollapsable::CollapseStatus & status) { status = InsetCollapsable::Collapsed; - string name; - string body = split(in, name, ' '); + istringstream data(in); + LyXLex lex(0,0); + lex.setStream(data); - if (body.empty()) + string name; + lex >> name; + if (name != name_) { + lyxerr << "InsetERTMailer::string2params(" << in << ")\n" + << "Missing identifier \"" << name_ << '"' << std::endl; return; + } - status = static_cast(strToInt(body)); + int s; + lex >> s; + if (lex) + status = static_cast(s); } string const InsetERTMailer::params2string(InsetCollapsable::CollapseStatus status) { - return name_ + ' ' + tostr(status); + ostringstream data; + data << name_ << ' ' << status; + return data.str(); } diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 7c7d888a2c..ba65ca17d5 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -63,7 +63,9 @@ namespace { external::DisplayType const defaultDisplayType = external::NoDisplay; -unsigned int defaultLyxScale = 100; +unsigned int const defaultLyxScale = 100; + +string const defaultTemplateName = "RasterImage"; } // namespace anon @@ -134,7 +136,8 @@ Translator const & displayTranslator() InsetExternalParams::InsetExternalParams() : display(defaultDisplayType), - lyxscale(defaultLyxScale) + lyxscale(defaultLyxScale), + templatename_(defaultTemplateName) {} @@ -372,7 +375,7 @@ bool InsetExternalParams::read(Buffer const & buffer, LyXLex & lex) } if (!found_end) - lex.printError("ExternalInset::read: Missing \\end_inset."); + lex.printError("ExternalInsetParams::read: Missing \\end_inset."); // This is a trick to make sure that the data are self-consistent. settemplate(templatename_);