From 4dbe411ba9f6aa3b9ed9bf0f867316d5b99192ea Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 13 Jul 2009 12:56:20 +0000 Subject: [PATCH] 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 --- src/Text3.cpp | 2 +- src/factory.cpp | 2 +- src/insets/Inset.cpp | 1 + src/insets/InsetBox.cpp | 2 +- src/insets/InsetBranch.cpp | 2 +- src/insets/InsetCollapsable.cpp | 10 +++++----- src/insets/InsetCollapsable.h | 4 ++-- src/insets/InsetFloat.cpp | 26 ++++++++++++-------------- src/insets/InsetFloat.h | 8 ++++---- src/insets/InsetInclude.cpp | 1 - src/insets/InsetIndex.cpp | 4 ++-- src/insets/InsetInfo.cpp | 4 ++-- src/insets/InsetLabel.cpp | 2 +- src/insets/InsetNote.cpp | 2 +- src/insets/InsetPhantom.cpp | 2 +- src/insets/InsetWrap.cpp | 6 +++--- 16 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index a29e6913d9..1bd1bcce3b 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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) { diff --git a/src/factory.cpp b/src/factory.cpp index 85c84d9b94..56bb5fbca4 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -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 p(new InsetFloat(buf, argument)); - p->setWide(true, params); + p->setWide(true); return p.release(); } lyxerr << "Non-existent float type: " << argument << endl; diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index daaa1493d5..dbefc1279d 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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); diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 4c80e3e6b4..1300533fee 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -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; } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 6a2519fee5..1e09c9c7a3 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -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; } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 71831aa22d..28c941c55a 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -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 diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 60674a3eca..3cb7aaad93 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -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(); /// diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index d4271da7d0..d70d356e7f 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -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 += '*'; diff --git a/src/insets/InsetFloat.h b/src/insets/InsetFloat.h index a5ea2ef64f..9ef3dcd9a9 100644 --- a/src/insets/InsetFloat.h +++ b/src/insets/InsetFloat.h @@ -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: diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index a652dbdbc4..6a09af87a4 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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: { diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index ad0e394bed..e64685335b 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -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; } diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 35a7e4475e..6875afd47b 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -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(); } diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 058b2ea656..93ccc40b28 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -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; } diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index c17b34b847..918e6f30c8 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -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: diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index ea4c7228a4..797049c1f6 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -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: diff --git a/src/insets/InsetWrap.cpp b/src/insets/InsetWrap.cpp index df10956dfd..2d28955644 100644 --- a/src/insets/InsetWrap.cpp +++ b/src/insets/InsetWrap.cpp @@ -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]";