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;
if (InsetCollapsable * ci = inset->asInsetCollapsable())
ci->setLayout(bparams);
ci->setLayout();
cur.recordUndo();
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());
if (params.documentClass().floats().typeExist(argument)) {
auto_ptr<InsetFloat> p(new InsetFloat(buf, argument));
p->setWide(true, params);
p->setWide(true);
return p.release();
}
lyxerr << "Non-existent float type: " << argument << endl;

View File

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

View File

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

View File

@ -136,7 +136,7 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
InsetBranchParams params;
InsetBranch::string2params(to_utf8(cmd.argument()), params);
params_.branch = params.branch;
setLayout(cur.buffer()->params());
setLayout();
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;
// this must be set before we enter InsetText::read()
setLayout(buffer().params());
setLayout();
InsetText::read(lex);
// set button label again as the inset contents was not read yet at
// setLayout() time.
@ -862,9 +862,9 @@ void InsetCollapsable::setStatus(Cursor & cur, CollapseStatus status)
}
docstring InsetCollapsable::floatName(
string const & type, BufferParams const & bp) const
docstring InsetCollapsable::floatName(string const & type) const
{
BufferParams const & bp = buffer().params();
FloatList const & floats = bp.documentClass().floats();
FloatList::const_iterator it = floats[type];
// FIXME UNICODE

View File

@ -47,7 +47,7 @@ public:
///
InsetLayout const & getLayout() const { return *layout_; }
///
void setLayout(BufferParams const &);
void setLayout();
/// (Re-)set the character style parameters from \p tc according
/// to name()
void setLayout(DocumentClass const * const tc);
@ -176,7 +176,7 @@ protected:
///
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();
///

View File

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

View File

@ -60,13 +60,13 @@ public:
///
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_; }
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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