Remove the layout_ cache in InsetCollapsable.

Remove setLayout methods and all the calls to it.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30560 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2009-07-14 12:07:51 +00:00
parent 24ae6d12d5
commit 5bf8df4fbc
11 changed files with 0 additions and 51 deletions

View File

@ -582,7 +582,6 @@ void switchBetweenClasses(DocumentClass const * const oldone,
if (inset->lyxCode() != FLEX_CODE) if (inset->lyxCode() != FLEX_CODE)
// FIXME: Should we verify all InsetCollapsable? // FIXME: Should we verify all InsetCollapsable?
continue; continue;
inset->setLayout(newone);
if (!inset->undefined()) if (!inset->undefined())
continue; continue;
// The flex inset is undefined in newtc // The flex inset is undefined in newtc

View File

@ -233,9 +233,6 @@ static bool doInsertInset(Cursor & cur, Text * text,
if (!inset) if (!inset)
return false; return false;
if (InsetCollapsable * ci = inset->asInsetCollapsable())
ci->setLayout();
cur.recordUndo(); cur.recordUndo();
if (cmd.action == LFUN_INDEX_INSERT) { if (cmd.action == LFUN_INDEX_INSERT) {
docstring ds = subst(text->getStringToIndex(cur), '\n', ' '); docstring ds = subst(text->getStringToIndex(cur), '\n', ' ');

View File

@ -213,7 +213,6 @@ 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();
break; break;
} }

View File

@ -136,7 +136,6 @@ 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();
break; break;
} }

View File

@ -109,7 +109,6 @@ InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype
: InsetText(buf, ltype), status_(Inset::Open), : InsetText(buf, ltype), status_(Inset::Open),
openinlined_(false), mouse_hover_(false) openinlined_(false), mouse_hover_(false)
{ {
setLayout(&buf.params().documentClass());
setAutoBreakRows(true); setAutoBreakRows(true);
setDrawFrame(true); setDrawFrame(true);
setFrameColor(Color_collapsableframe); setFrameColor(Color_collapsableframe);
@ -119,7 +118,6 @@ InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype
InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs) InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
: InsetText(rhs), : InsetText(rhs),
status_(rhs.status_), status_(rhs.status_),
layout_(rhs.layout_),
labelstring_(rhs.labelstring_), labelstring_(rhs.labelstring_),
button_dim(rhs.button_dim), button_dim(rhs.button_dim),
openinlined_(rhs.openinlined_), openinlined_(rhs.openinlined_),
@ -146,26 +144,6 @@ docstring InsetCollapsable::toolTip(BufferView const & bv, int x, int y) const
} }
void InsetCollapsable::setLayout()
{
setLayout(buffer().params().documentClassPtr());
}
void InsetCollapsable::setLayout(DocumentClass const * const dc)
{
if (dc) {
layout_ = &(dc->insetLayout(name()));
labelstring_ = translateIfPossible(getLayout().labelstring());
} else {
layout_ = &DocumentClass::plainInsetLayout();
labelstring_ = _("UNDEFINED");
}
setButtonLabel();
}
void InsetCollapsable::write(ostream & os) const void InsetCollapsable::write(ostream & os) const
{ {
os << "status "; os << "status ";
@ -192,10 +170,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();
InsetText::read(lex); InsetText::read(lex);
// set button label again as the inset contents was not read yet at
// setLayout() time.
setButtonLabel(); setButtonLabel();
// Force default font, if so requested // Force default font, if so requested
@ -211,7 +186,6 @@ void InsetCollapsable::read(Lexer & lex)
Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const
{ {
LASSERT(layout_, /**/);
Dimension dim; Dimension dim;
theFontMetrics(getLayout().labelfont()).buttonText( theFontMetrics(getLayout().labelfont()).buttonText(
buttonLabel(bv), dim.wid, dim.asc, dim.des); buttonLabel(bv), dim.wid, dim.asc, dim.des);

View File

@ -44,15 +44,6 @@ public:
docstring toolTip(BufferView const & bv, int x, int y) const; docstring toolTip(BufferView const & bv, int x, int y) const;
/// ///
docstring name() const { return from_ascii("Collapsable"); } docstring name() const { return from_ascii("Collapsable"); }
#if 0
///
InsetLayout const & getLayout() const { return *layout_; }
#endif
///
void setLayout();
/// (Re-)set the character style parameters from \p tc according
/// to name()
void setLayout(DocumentClass const * const tc);
/// ///
void read(Lexer &); void read(Lexer &);
/// ///
@ -172,8 +163,6 @@ protected:
/// ///
mutable CollapseStatus status_; mutable CollapseStatus status_;
private: private:
/// cache for the layout_. Make sure it is in sync with the document class!
InsetLayout const * layout_;
/// ///
Dimension dimensionCollapsed(BufferView const & bv) const; Dimension dimensionCollapsed(BufferView const & bv) const;
/// ///

View File

@ -30,8 +30,6 @@ namespace lyx {
InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName) InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName)
: InsetCollapsable(buf), name_(layoutName) : InsetCollapsable(buf), name_(layoutName)
{ {
// again, because now the name is initialized
setLayout(buf.params().documentClassPtr());
status_= Collapsed; status_= Collapsed;
} }

View File

@ -192,13 +192,11 @@ 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();
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();
break; break;
} }

View File

@ -139,7 +139,6 @@ void InsetInfo::read(Lexer & lex)
_("Missing \\end_inset at this point."), _("Missing \\end_inset at this point."),
from_utf8(token)); from_utf8(token));
} }
setLayout();
updateInfo(); updateInfo();
} }
@ -244,7 +243,6 @@ 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();
updateInfo(); updateInfo();
} }

View File

@ -181,7 +181,6 @@ 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();
break; break;
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE:

View File

@ -266,7 +266,6 @@ 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();
break; break;
case LFUN_INSET_DIALOG_UPDATE: case LFUN_INSET_DIALOG_UPDATE: