From 5bf8df4fbc9a4117df3df957f83c23f6847ac185 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 12:07:51 +0000 Subject: [PATCH] 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 --- src/CutAndPaste.cpp | 1 - src/Text3.cpp | 3 --- src/insets/InsetBox.cpp | 1 - src/insets/InsetBranch.cpp | 1 - src/insets/InsetCollapsable.cpp | 26 -------------------------- src/insets/InsetCollapsable.h | 11 ----------- src/insets/InsetFlex.cpp | 2 -- src/insets/InsetIndex.cpp | 2 -- src/insets/InsetInfo.cpp | 2 -- src/insets/InsetNote.cpp | 1 - src/insets/InsetPhantom.cpp | 1 - 11 files changed, 51 deletions(-) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index b85aa21c34..f92d74dca2 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -582,7 +582,6 @@ void switchBetweenClasses(DocumentClass const * const oldone, if (inset->lyxCode() != FLEX_CODE) // FIXME: Should we verify all InsetCollapsable? continue; - inset->setLayout(newone); if (!inset->undefined()) continue; // The flex inset is undefined in newtc diff --git a/src/Text3.cpp b/src/Text3.cpp index 1bd1bcce3b..5f32da6e22 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -233,9 +233,6 @@ static bool doInsertInset(Cursor & cur, Text * text, if (!inset) return false; - if (InsetCollapsable * ci = inset->asInsetCollapsable()) - ci->setLayout(); - cur.recordUndo(); if (cmd.action == LFUN_INDEX_INSERT) { docstring ds = subst(text->getStringToIndex(cur), '\n', ' '); diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index 1300533fee..ecf9f4fb94 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -213,7 +213,6 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd) params_.type = cmd.getArg(1); else string2params(to_utf8(cmd.argument()), params_); - setLayout(); break; } diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index 1e09c9c7a3..17960a2344 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -136,7 +136,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd) InsetBranchParams params; InsetBranch::string2params(to_utf8(cmd.argument()), params); params_.branch = params.branch; - setLayout(); break; } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index e35ad10cba..51c7048a40 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -109,7 +109,6 @@ InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype : InsetText(buf, ltype), status_(Inset::Open), openinlined_(false), mouse_hover_(false) { - setLayout(&buf.params().documentClass()); setAutoBreakRows(true); setDrawFrame(true); setFrameColor(Color_collapsableframe); @@ -119,7 +118,6 @@ InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs) : InsetText(rhs), status_(rhs.status_), - layout_(rhs.layout_), labelstring_(rhs.labelstring_), button_dim(rhs.button_dim), 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 { os << "status "; @@ -192,10 +170,7 @@ void InsetCollapsable::read(Lexer & lex) status_ = Open; // this must be set before we enter InsetText::read() - setLayout(); InsetText::read(lex); - // set button label again as the inset contents was not read yet at - // setLayout() time. setButtonLabel(); // Force default font, if so requested @@ -211,7 +186,6 @@ void InsetCollapsable::read(Lexer & lex) Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const { - LASSERT(layout_, /**/); Dimension dim; theFontMetrics(getLayout().labelfont()).buttonText( buttonLabel(bv), dim.wid, dim.asc, dim.des); diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 41c79334fc..0ed8bcf63f 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -44,15 +44,6 @@ public: docstring toolTip(BufferView const & bv, int x, int y) const; /// 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 &); /// @@ -172,8 +163,6 @@ protected: /// mutable CollapseStatus status_; private: - /// cache for the layout_. Make sure it is in sync with the document class! - InsetLayout const * layout_; /// Dimension dimensionCollapsed(BufferView const & bv) const; /// diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 80c755bc28..be73041741 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -30,8 +30,6 @@ namespace lyx { InsetFlex::InsetFlex(Buffer const & buf, string const & layoutName) : InsetCollapsable(buf), name_(layoutName) { - // again, because now the name is initialized - setLayout(buf.params().documentClassPtr()); status_= Collapsed; } diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index e64685335b..cb3a276741 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -192,13 +192,11 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { if (cmd.getArg(0) == "changetype") { params_.index = from_utf8(cmd.getArg(1)); - setLayout(); break; } InsetIndexParams params; InsetIndex::string2params(to_utf8(cmd.argument()), params); params_.index = params.index; - setLayout(); break; } diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 6875afd47b..fa76971073 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -139,7 +139,6 @@ void InsetInfo::read(Lexer & lex) _("Missing \\end_inset at this point."), from_utf8(token)); } - setLayout(); updateInfo(); } @@ -244,7 +243,6 @@ void InsetInfo::setInfo(string const & name) string type; name_ = trim(split(name, type, ' ')); type_ = nameTranslator().find(type); - setLayout(); updateInfo(); } diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 918e6f30c8..4cbe6172bc 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -181,7 +181,6 @@ void InsetNote::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: string2params(to_utf8(cmd.argument()), params_); - setLayout(); break; case LFUN_INSET_DIALOG_UPDATE: diff --git a/src/insets/InsetPhantom.cpp b/src/insets/InsetPhantom.cpp index 797049c1f6..2f5daf07e3 100644 --- a/src/insets/InsetPhantom.cpp +++ b/src/insets/InsetPhantom.cpp @@ -266,7 +266,6 @@ void InsetPhantom::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: string2params(to_utf8(cmd.argument()), params_); - setLayout(); break; case LFUN_INSET_DIALOG_UPDATE: