+
# Standard textclass definition file. Taken from initial LyX source code
# Author : Matthias Ettrich <ettrich@informatik.uni-tuebingen.de>
# Transposed by Pascal André <andre@via.ecp.fr>
AlignPossible Block, Left
LabelType Counter_EnumI
End
+
+
+#
+# New environments (not active yet)
+#
+#Environment Itemize
+# LaTeXHeader "\begin{itemize}"
+# LaTeXFooter "\end{itemize}"
+# LabelString *
+# Margin Static
+# LatexType Item_Environment
+# NextNoIndent 1
+# LeftMargin MMN
+# LabelSep xx
+# ItemSep 0.2
+# TopSep 0.7
+# BottomSep 0.7
+# ParSep 0.3
+# Align Block
+# AlignPossible Block, Left
+# LabelType Static
+#End
+
+#Environment Enumerate
+# Margin Static
+# LatexType Item_Environment
+# LatexName enumerate
+# NextNoIndent 1
+# LeftMargin MMN
+# LabelSep xx
+# ParSkip 0.0
+# ItemSep 0.2
+# TopSep 0.7
+# BottomSep 0.7
+# ParSep 0.3
+# Align Block
+# AlignPossible Block, Left
+# LabelType Counter_EnumI
+#End
+
namespace { // anon
struct compare_name {
+
compare_name(string const & name)
- : name_(name) {}
- template <class C>
- bool operator()(C & c) {
+ : name_(name)
+ {}
+
+ bool operator()(boost::shared_ptr<LyXLayout> const & c)
+ {
+ //lyxerr << "comparing '" << name_ << "' to '" << c->name() << "'\n";
return c->name() == name_;
}
+
string name_;
+
};
} // anon
TC_COUNTER,
TC_NOFLOAT,
TC_TITLELATEXNAME,
- TC_TITLELATEXTYPE
+ TC_TITLELATEXTYPE,
+ TC_ENVIRONMENT
};
// Reads a textclass structure from file.
string const name = subst(lexrc.getString(),
'_', ' ');
if (hasLayout(name)) {
- LyXLayout * lay =
- operator[](name).get();
+ LyXLayout * lay = operator[](name).get();
error = do_readStyle(lexrc, *lay);
} else {
LyXLayout lay;
}
break;
+ case TC_ENVIRONMENT:
+ if (lexrc.next()) {
+ string const name = subst(lexrc.getString(),
+ '_', ' ');
+ if (hasLayout(name)) {
+ LyXLayout * lay = operator[](name).get();
+ error = do_readStyle(lexrc, *lay);
+ } else {
+ LyXLayout lay;
+ lay.setName(name);
+ if (!(error = do_readStyle(lexrc, lay)))
+ envlist_.push_back
+ (boost::shared_ptr<LyXLayout>(new LyXLayout(lay)));
+ else
+ lexrc.printError("Problems reading environment: `$$Token'.");
+ }
+ }
+ else {
+ lexrc.printError("No name given for style: `$$Token'.");
+ error = true;
+ }
+ break;
+
case TC_NOSTYLE:
if (lexrc.next()) {
string const style = subst(lexrc.getString(),
lyx::Assert(!n.empty());
if (n.empty())
- lyxerr << "Operator[] called with empty n" << endl;
+ lyxerr << "LyXTextClass::operator[] called with empty n" << endl;
string const name = (n.empty() ? defaultLayoutName() : n);
}
+LyXLayout_ptr const & LyXTextClass::getEnv(string const & name) const
+{
+ lyx::Assert(!name.empty());
+
+ if (name.empty())
+ lyxerr << "LyXTextClass::getEnv() called with empty n" << endl;
+
+ LayoutList::const_iterator cit =
+ find_if(envlist_.begin(), envlist_.end(), compare_name(name));
+
+ if (cit == envlist_.end()) {
+ lyxerr << "We failed to find the environment '" << name
+ << "' in the layout list. You MUST investigate!"
+ << endl;
+ // we require the name to exist
+ lyx::Assert(false);
+ }
+
+ return *cit;
+}
+
+
bool LyXTextClass::delete_layout(string const & name)
{
if (name == defaultLayoutName())
///
LyXLayout_ptr const & operator[](string const & vname) const;
+ ///
+ LyXLayout_ptr const & getEnv(string const & vname) const;
/// Sees to that the textclass structure has been loaded
bool load() const;
///
bool delete_layout(string const &);
///
+ bool delete_env(string const &);
+ ///
bool do_readStyle(LyXLex &, LyXLayout &);
/// Layout file name
string name_;
/// Paragraph styles used in this layout
LayoutList layoutlist_;
+ /// Environment styles used in this layout
+ LayoutList envlist_;
+
/// available types of float, eg. figure, algorithm.
boost::shared_ptr<FloatList> floatlist_;