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
This commit is contained in:
Angus Leeming 2003-12-10 21:32:05 +00:00
parent c2d7777341
commit d3990cdad5
3 changed files with 35 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2003-12-10 Angus Leeming <leeming@lyx.org>
* 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 <leeming@lyx.org>
* insetnote.[Ch]: change the storage type of InsetNoteParams::type

View File

@ -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;
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
string name;
string body = split(in, name, ' ');
if (body.empty())
lex >> name;
if (name != name_) {
lyxerr << "InsetERTMailer::string2params(" << in << ")\n"
<< "Missing identifier \"" << name_ << '"' << std::endl;
return;
}
status = static_cast<InsetCollapsable::CollapseStatus>(strToInt(body));
int s;
lex >> s;
if (lex)
status = static_cast<InsetCollapsable::CollapseStatus>(s);
}
string const
InsetERTMailer::params2string(InsetCollapsable::CollapseStatus status)
{
return name_ + ' ' + tostr(status);
ostringstream data;
data << name_ << ' ' << status;
return data.str();
}

View File

@ -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<DisplayType, string> 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_);