mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
more environment infrastructure
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6501 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d08db91ed0
commit
6bc54517df
@ -1,3 +1,4 @@
|
||||
|
||||
# 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>
|
||||
@ -112,3 +113,43 @@ Style Bibliography
|
||||
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
|
||||
|
||||
|
@ -32,13 +32,19 @@ using std::ostream;
|
||||
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
|
||||
@ -107,7 +113,8 @@ enum TextClassTags {
|
||||
TC_COUNTER,
|
||||
TC_NOFLOAT,
|
||||
TC_TITLELATEXNAME,
|
||||
TC_TITLELATEXTYPE
|
||||
TC_TITLELATEXTYPE,
|
||||
TC_ENVIRONMENT
|
||||
};
|
||||
|
||||
// Reads a textclass structure from file.
|
||||
@ -201,8 +208,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
||||
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;
|
||||
@ -224,6 +230,29 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
||||
}
|
||||
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(),
|
||||
@ -732,7 +761,7 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
|
||||
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);
|
||||
|
||||
@ -763,6 +792,28 @@ LyXLayout_ptr const & LyXTextClass::operator[](string const & n) const
|
||||
}
|
||||
|
||||
|
||||
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())
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
|
||||
///
|
||||
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;
|
||||
@ -149,6 +151,8 @@ private:
|
||||
///
|
||||
bool delete_layout(string const &);
|
||||
///
|
||||
bool delete_env(string const &);
|
||||
///
|
||||
bool do_readStyle(LyXLex &, LyXLayout &);
|
||||
/// Layout file name
|
||||
string name_;
|
||||
@ -202,6 +206,9 @@ private:
|
||||
/// 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_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user