NOTE: Some cleanup is needed here, and I'll do it shortly. Doing it properly, though, requires making InsetLayout a proper class. (At the moment, it's just a C-style struct.) That should be committed separately.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23103
a592a061-630c-0410-9148-
cb99ea01b6c8
// FIXME: Should we verify all InsetCollapsable?
continue;
inset->setLayout(newone);
- if (inset->getLayout().labelstring != from_utf8("UNDEFINED"))
+ if (!inset->undefined())
continue;
// The flex inset is undefined in newtc
docstring const s = bformat(_(
docstring const TextClass::emptylayout_ = from_ascii("PlainLayout");
+InsetLayout TextClass::empty_insetlayout_;
+
+
bool TextClass::isTeXClassAvailable() const
{
return texClassAvail_;
break;
n = n.substr(0,i);
}
- static InsetLayout empty;
- empty.labelstring = from_utf8("UNDEFINED");
- empty.labelfont = sane_font;
- empty.labelfont.setColor(Color_error);
- empty.bgcolor = Color_error;
- return empty;
+ return empty_insetlayout_;
}
int max_toclevel() const;
/// returns true if the class has a ToC structure
bool hasTocLevels() const;
+ ///
+ static InsetLayout const & emptyInsetLayout() { return empty_insetlayout_; }
private:
///
bool deleteLayout(docstring const &);
int min_toclevel_;
/// The maximal TocLevel of sectioning layouts
int max_toclevel_;
+ ///
+ static InsetLayout empty_insetlayout_;
};
layout_ = &tc->insetlayout(name());
labelstring_ = layout_->labelstring;
} else {
- layout_ = 0;
+ layout_ = &TextClass::emptyInsetLayout();
labelstring_ = _("UNDEFINED");
}
}
+bool InsetCollapsable::undefined() const
+{
+ std::string const & n = getLayout().name;
+ return n.empty() || n == TextClass::emptyInsetLayout().name;
+}
+
+
} // namespace lyx
virtual bool forceLTR() const { return layout_->forceltr; }
///
virtual bool useEmptyLayout() const { return true; }
-
+ /// Is this inset's layout defined in the document's textclass?
+ /// May be wrong after textclass change or paste from another document
+ bool undefined() const;
protected:
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
}
-bool InsetFlex::undefined() const
-{
- return getLayout().labelstring == from_utf8("UNDEFINED");
-}
-
-
docstring const InsetFlex::editMessage() const
{
return _("Opened Flex Inset");
///
docstring name() const { return from_utf8(name_); }
- /// Is this character style defined in the document's textclass?
- /// May be wrong after textclass change or paste from another document
- bool undefined() const;
///
virtual docstring const editMessage() const;
///
///
class InsetLayout {
public:
+ InsetLayout() :
+ name("undefined"),
+ labelstring(from_utf8("UNDEFINED")),
+ font(sane_font), labelfont(sane_font),
+ bgcolor(Color_error)
+ { labelfont.setColor(Color_error); };
std::string name;
std::string lyxtype;
docstring labelstring;