Remove all BufferParam arguments in InsetXXX methods (since insets know about their Buffer)

Add an assertion in Inset::dispatch that checks that buffer() == *cur.buffer()


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30540 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2009-07-13 12:56:20 +00:00
parent af905aaff6
commit 4dbe411ba9
16 changed files with 38 additions and 40 deletions

View File

@ -234,7 +234,7 @@ static bool doInsertInset(Cursor & cur, Text * text,
return false; return false;
if (InsetCollapsable * ci = inset->asInsetCollapsable()) if (InsetCollapsable * ci = inset->asInsetCollapsable())
ci->setLayout(bparams); ci->setLayout();
cur.recordUndo(); cur.recordUndo();
if (cmd.action == LFUN_INDEX_INSERT) { if (cmd.action == LFUN_INDEX_INSERT) {

View File

@ -161,7 +161,7 @@ Inset * createInsetHelper(Buffer & buf, FuncRequest const & cmd)
string const argument = to_utf8(cmd.argument()); string const argument = to_utf8(cmd.argument());
if (params.documentClass().floats().typeExist(argument)) { if (params.documentClass().floats().typeExist(argument)) {
auto_ptr<InsetFloat> p(new InsetFloat(buf, argument)); auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
p->setWide(true, params); p->setWide(true);
return p.release(); return p.release();
} }
lyxerr << "Non-existent float type: " << argument << endl; lyxerr << "Non-existent float type: " << argument << endl;

View File

@ -210,6 +210,7 @@ string insetName(InsetCode c)
void Inset::dispatch(Cursor & cur, FuncRequest & cmd) void Inset::dispatch(Cursor & cur, FuncRequest & cmd)
{ {
LASSERT(cur.buffer() == &buffer(), return);
cur.updateFlags(Update::Force | Update::FitCursor); cur.updateFlags(Update::Force | Update::FitCursor);
cur.dispatched(); cur.dispatched();
doDispatch(cur, cmd); doDispatch(cur, cmd);

View File

@ -213,7 +213,7 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
params_.type = cmd.getArg(1); params_.type = cmd.getArg(1);
else else
string2params(to_utf8(cmd.argument()), params_); string2params(to_utf8(cmd.argument()), params_);
setLayout(cur.buffer()->params()); setLayout();
break; break;
} }

View File

@ -136,7 +136,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
InsetBranchParams params; InsetBranchParams params;
InsetBranch::string2params(to_utf8(cmd.argument()), params); InsetBranch::string2params(to_utf8(cmd.argument()), params);
params_.branch = params.branch; params_.branch = params.branch;
setLayout(cur.buffer()->params()); setLayout();
break; break;
} }

View File

@ -146,9 +146,9 @@ docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
} }
void InsetCollapsable::setLayout(BufferParams const & bp) void InsetCollapsable::setLayout()
{ {
setLayout(bp.documentClassPtr()); setLayout(buffer().params().documentClassPtr());
} }
@ -192,7 +192,7 @@ void InsetCollapsable::read(Lexer & lex)
status_ = Open; status_ = Open;
// this must be set before we enter InsetText::read() // this must be set before we enter InsetText::read()
setLayout(buffer().params()); setLayout();
InsetText::read(lex); InsetText::read(lex);
// set button label again as the inset contents was not read yet at // set button label again as the inset contents was not read yet at
// setLayout() time. // setLayout() time.
@ -862,9 +862,9 @@ void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status)
} }
docstring InsetCollapsable::floatName( docstring InsetCollapsable::floatName(string const & type) const
string const & type, BufferParams const & bp) const
{ {
BufferParams const & bp = buffer().params();
FloatList const & floats = bp.documentClass().floats(); FloatList const & floats = bp.documentClass().floats();
FloatList::const_iterator it = floats[type]; FloatList::const_iterator it = floats[type];
// FIXME UNICODE // FIXME UNICODE

View File

@ -47,7 +47,7 @@ public:
/// ///
InsetLayout const & getLayout() const { return *layout_; } InsetLayout const & getLayout() const { return *layout_; }
/// ///
void setLayout(BufferParams const &); void setLayout();
/// (Re-)set the character style parameters from \p tc according /// (Re-)set the character style parameters from \p tc according
/// to name() /// to name()
void setLayout(DocumentClass const * const tc); void setLayout(DocumentClass const * const tc);
@ -176,7 +176,7 @@ protected:
/// ///
Inset * editXY(Cursor & cur, int x, int y); Inset * editXY(Cursor & cur, int x, int y);
/// ///
docstring floatName(std::string const & type, BufferParams const &) const; docstring floatName(std::string const & type) const;
/// ///
virtual void resetParagraphsFont(); virtual void resetParagraphsFont();
/// ///

View File

@ -113,7 +113,7 @@ namespace lyx {
InsetFloat::InsetFloat(Buffer const & buf, string const & type) InsetFloat::InsetFloat(Buffer const & buf, string const & type)
: InsetCollapsable(buf), name_(from_utf8(type)) : InsetCollapsable(buf), name_(from_utf8(type))
{ {
setLabel(_("float: ") + floatName(type, buf.params())); setLabel(_("float: ") + floatName(type));
params_.type = type; params_.type = type;
} }
@ -153,11 +153,9 @@ void InsetFloat::doDispatch(Cursor & cur, FuncRequest & cmd)
params_.placement = params.placement; params_.placement = params.placement;
params_.wide = params.wide; params_.wide = params.wide;
params_.sideways = params.sideways; params_.sideways = params.sideways;
setWide(params_.wide, cur.buffer()->params(), false);
setSideways(params_.sideways, cur.buffer()->params(), false);
} }
setNewLabel(cur.buffer()->params()); setNewLabel();
break; break;
} }
@ -201,7 +199,7 @@ void InsetFloat::updateLabels(ParIterator const & it)
// floats can only embed subfloats of their own kind // floats can only embed subfloats of their own kind
if (subflt) if (subflt)
params_.type = saveflt; params_.type = saveflt;
setSubfloat(subflt, buffer().params()); setSubfloat(subflt);
// Tell to captions what the current float is // Tell to captions what the current float is
cnts.current_float(params().type); cnts.current_float(params().type);
@ -383,7 +381,7 @@ int InsetFloat::latex(odocstream & os, OutputParams const & runparams_in) const
int InsetFloat::plaintext(odocstream & os, OutputParams const & runparams) const int InsetFloat::plaintext(odocstream & os, OutputParams const & runparams) const
{ {
os << '[' << buffer().B_("float") << ' ' os << '[' << buffer().B_("float") << ' '
<< floatName(params_.type, buffer().params()) << ":\n"; << floatName(params_.type) << ":\n";
InsetText::plaintext(os, runparams); InsetText::plaintext(os, runparams);
os << "\n]"; os << "\n]";
@ -420,38 +418,38 @@ bool InsetFloat::showInsetDialog(BufferView * bv) const
} }
void InsetFloat::setWide(bool w, BufferParams const & bp, bool update_label) void InsetFloat::setWide(bool w, bool update_label)
{ {
params_.wide = w; params_.wide = w;
if (update_label) if (update_label)
setNewLabel(bp); setNewLabel();
} }
void InsetFloat::setSideways(bool s, BufferParams const & bp, bool update_label) void InsetFloat::setSideways(bool s, bool update_label)
{ {
params_.sideways = s; params_.sideways = s;
if (update_label) if (update_label)
setNewLabel(bp); setNewLabel();
} }
void InsetFloat::setSubfloat(bool s, BufferParams const & bp, bool update_label) void InsetFloat::setSubfloat(bool s, bool update_label)
{ {
params_.subfloat = s; params_.subfloat = s;
if (update_label) if (update_label)
setNewLabel(bp); setNewLabel();
} }
void InsetFloat::setNewLabel(BufferParams const & bp) void InsetFloat::setNewLabel()
{ {
docstring lab = _("float: "); docstring lab = _("float: ");
if (params_.subfloat) if (params_.subfloat)
lab = _("subfloat: "); lab = _("subfloat: ");
lab += floatName(params_.type, bp); lab += floatName(params_.type);
if (params_.wide) if (params_.wide)
lab += '*'; lab += '*';

View File

@ -60,13 +60,13 @@ public:
/// ///
static std::string params2string(InsetFloatParams const &); static std::string params2string(InsetFloatParams const &);
/// ///
void setWide(bool w, BufferParams const &, bool update_label = true); void setWide(bool w, bool update_label = true);
/// ///
void setSideways(bool s, BufferParams const &, bool update_label = true); void setSideways(bool s, bool update_label = true);
/// ///
void setSubfloat(bool s, BufferParams const &, bool update_label = true); void setSubfloat(bool s, bool update_label = true);
/// ///
void setNewLabel(BufferParams const &); void setNewLabel();
/// ///
InsetFloatParams const & params() const { return params_; } InsetFloatParams const & params() const { return params_; }
private: private:

View File

@ -221,7 +221,6 @@ bool InsetInclude::isCompatibleCommand(string const & s)
void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd) void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
{ {
LASSERT(cur.buffer() == &buffer(), return);
switch (cmd.action) { switch (cmd.action) {
case LFUN_INSET_EDIT: { case LFUN_INSET_EDIT: {

View File

@ -192,13 +192,13 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INSET_MODIFY: { case LFUN_INSET_MODIFY: {
if (cmd.getArg(0) == "changetype") { if (cmd.getArg(0) == "changetype") {
params_.index = from_utf8(cmd.getArg(1)); params_.index = from_utf8(cmd.getArg(1));
setLayout(cur.buffer()->params()); setLayout();
break; break;
} }
InsetIndexParams params; InsetIndexParams params;
InsetIndex::string2params(to_utf8(cmd.argument()), params); InsetIndex::string2params(to_utf8(cmd.argument()), params);
params_.index = params.index; params_.index = params.index;
setLayout(cur.buffer()->params()); setLayout();
break; break;
} }

View File

@ -139,7 +139,7 @@ void InsetInfo::read(Lexer & lex)
_("Missing \\end_inset at this point."), _("Missing \\end_inset at this point."),
from_utf8(token)); from_utf8(token));
} }
setLayout(buffer().params()); setLayout();
updateInfo(); updateInfo();
} }
@ -244,7 +244,7 @@ void InsetInfo::setInfo(string const & name)
string type; string type;
name_ = trim(split(name, type, ' ')); name_ = trim(split(name, type, ' '));
type_ = nameTranslator().find(type); type_ = nameTranslator().find(type);
setLayout(buffer().params()); setLayout();
updateInfo(); updateInfo();
} }

View File

@ -176,7 +176,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
InsetCommandParams p(REF_CODE, "ref"); InsetCommandParams p(REF_CODE, "ref");
p["reference"] = getParam("name"); p["reference"] = getParam("name");
cap::clearSelection(); cap::clearSelection();
cap::copyInset(cur, new InsetRef(*cur.buffer(), p), getParam("name")); cap::copyInset(cur, new InsetRef(buffer(), p), getParam("name"));
break; break;
} }

View File

@ -181,7 +181,7 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INSET_MODIFY: case LFUN_INSET_MODIFY:
string2params(to_utf8(cmd.argument()), params_); string2params(to_utf8(cmd.argument()), params_);
setLayout(buffer().params()); setLayout();
break; break;
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE:

View File

@ -266,7 +266,7 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INSET_MODIFY: case LFUN_INSET_MODIFY:
string2params(to_utf8(cmd.argument()), params_); string2params(to_utf8(cmd.argument()), params_);
setLayout(buffer().params()); setLayout();
break; break;
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE:

View File

@ -42,7 +42,7 @@ namespace lyx {
InsetWrap::InsetWrap(Buffer const & buf, string const & type) InsetWrap::InsetWrap(Buffer const & buf, string const & type)
: InsetCollapsable(buf) : InsetCollapsable(buf)
{ {
setLabel(_("wrap: ") + floatName(type, buf.params())); setLabel(_("wrap: ") + floatName(type));
params_.type = type; params_.type = type;
params_.lines = 0; params_.lines = 0;
params_.placement = "o"; params_.placement = "o";
@ -115,7 +115,7 @@ bool InsetWrap::getStatus(Cursor & cur, FuncRequest const & cmd,
void InsetWrap::updateLabels(ParIterator const & it) void InsetWrap::updateLabels(ParIterator const & it)
{ {
setLabel(_("wrap: ") + floatName(params_.type, buffer().params())); setLabel(_("wrap: ") + floatName(params_.type));
Counters & cnts = Counters & cnts =
buffer().masterBuffer()->params().documentClass().counters(); buffer().masterBuffer()->params().documentClass().counters();
string const saveflt = cnts.current_float(); string const saveflt = cnts.current_float();
@ -202,7 +202,7 @@ int InsetWrap::latex(odocstream & os, OutputParams const & runparams_in) const
int InsetWrap::plaintext(odocstream & os, OutputParams const & runparams) const int InsetWrap::plaintext(odocstream & os, OutputParams const & runparams) const
{ {
os << '[' << buffer().B_("wrap") << ' ' os << '[' << buffer().B_("wrap") << ' '
<< floatName(params_.type, buffer().params()) << ":\n"; << floatName(params_.type) << ":\n";
InsetText::plaintext(os, runparams); InsetText::plaintext(os, runparams);
os << "\n]"; os << "\n]";