From f1f8ce2d1f7b296102fe9848d26346a6f35ec521 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 15 Sep 2003 15:51:48 +0000 Subject: [PATCH] the toc fix plus layout stuff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7761 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/lyxlayout.C | 14 ++++++++++---- src/lyxlayout.h | 2 ++ src/lyxtextclass.C | 17 ----------------- src/lyxtextclass.h | 8 +++----- src/toc.C | 14 ++++---------- 5 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/lyxlayout.C b/src/lyxlayout.C index bb43bd72f1..c785dc19a4 100644 --- a/src/lyxlayout.C +++ b/src/lyxlayout.C @@ -78,6 +78,7 @@ enum LayoutTags { LT_RIGHTMARGIN, LT_SPACING, LT_TOPSEP, + LT_TOCLEVEL, LT_INTITLE }; @@ -115,6 +116,7 @@ LyXLayout::LyXLayout () free_spacing = false; pass_thru = false; is_environment = false; + toclevel = 0; } @@ -167,6 +169,7 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) { "rightmargin", LT_RIGHTMARGIN }, { "spacing", LT_SPACING }, { "textfont", LT_TEXTFONT }, + { "toclevel", LT_TOCLEVEL }, { "topsep", LT_TOPSEP } }; @@ -241,9 +244,8 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) break; case LT_DEPENDSON: - if (lexrc.next()) { + if (lexrc.next()) depends_on_ = lexrc.getString(); - } break; case LT_MARGIN: // margin style definition. @@ -273,10 +275,14 @@ bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) intitle = lexrc.next() && lexrc.getInteger(); break; + case LT_TOCLEVEL: + lexrc.next(); + toclevel = lexrc.getInteger(); + break; + case LT_OPTARGS: - if (lexrc.next()) { + if (lexrc.next()) optionalargs = lexrc.getInteger(); - } break; case LT_NEED_PROTECT: diff --git a/src/lyxlayout.h b/src/lyxlayout.h index 67e2d57bf0..f2a87f895f 100644 --- a/src/lyxlayout.h +++ b/src/lyxlayout.h @@ -140,6 +140,8 @@ public: bool pass_thru; /// bool is_environment; + /// show this in toc + int toclevel; /// for new environment insets string latexheader; /// for new environment insets diff --git a/src/lyxtextclass.C b/src/lyxtextclass.C index 5231cf12ac..fb53e5e742 100644 --- a/src/lyxtextclass.C +++ b/src/lyxtextclass.C @@ -67,7 +67,6 @@ LyXTextClass::LyXTextClass(string const & fn, string const & cln, secnumdepth_ = 3; tocdepth_ = 3; pagestyle_ = "default"; - maxcounter_ = 4; defaultfont_ = LyXFont(LyXFont::ALL_SANE); opt_fontsize_ = "10|11|12"; opt_pagestyle_ = "empty|plain|headings|fancy"; @@ -111,7 +110,6 @@ enum TextClassTags { TC_SIDES, TC_PAGESTYLE, TC_DEFAULTFONT, - TC_MAXCOUNTER, TC_SECNUMDEPTH, TC_TOCDEPTH, TC_CLASSOPTIONS, @@ -142,7 +140,6 @@ bool LyXTextClass::Read(string const & filename, bool merge) { "float", TC_FLOAT }, { "input", TC_INPUT }, { "leftmargin", TC_LEFTMARGIN }, - { "maxcounter", TC_MAXCOUNTER }, { "nofloat", TC_NOFLOAT }, { "nostyle", TC_NOSTYLE }, { "outputtype", TC_OUTPUTTYPE }, @@ -299,11 +296,6 @@ bool LyXTextClass::Read(string const & filename, bool merge) } break; - case TC_MAXCOUNTER: - lexrc.next(); - maxcounter_ = lexrc.getInteger(); - break; - case TC_SECNUMDEPTH: lexrc.next(); secnumdepth_ = lexrc.getInteger(); @@ -880,12 +872,6 @@ unsigned int LyXTextClass::columns() const } -int LyXTextClass::maxcounter() const -{ - return maxcounter_; -} - - LYX_TITLE_LATEX_TYPES LyXTextClass::titletype() const { return titletype_; @@ -898,9 +884,6 @@ string const & LyXTextClass::titlename() const } - - - int LyXTextClass::size() const { return layoutlist_.size(); diff --git a/src/lyxtextclass.h b/src/lyxtextclass.h index 3de520654c..56232ce039 100644 --- a/src/lyxtextclass.h +++ b/src/lyxtextclass.h @@ -13,15 +13,17 @@ #include "lyxlayout.h" #include "lyxlayout_ptr_fwd.h" +#include "support/std_string.h" + #include -#include "support/std_string.h" #include class LyXLex; class Counters; class FloatList; + /// Stores the layout specification of a LyX document class. class LyXTextClass { public: @@ -137,8 +139,6 @@ public: /// Text that dictates how wide the right margin is on the screen string const & rightmargin() const; - /// - int maxcounter() const; /// The type of command used to produce a title LYX_TITLE_LATEX_TYPES titletype() const; @@ -193,8 +193,6 @@ private: /// Text that dictates how wide the right margin is on the screen string rightmargin_; - /// highest header level used in this layout. - int maxcounter_; // add approp. signedness /// The type of command used to produce a title LYX_TITLE_LATEX_TYPES titletype_; diff --git a/src/toc.C b/src/toc.C index 719870dc67..0338f3f98a 100644 --- a/src/toc.C +++ b/src/toc.C @@ -75,16 +75,10 @@ TocList const getTocList(Buffer const & buf) ParConstIterator end = buf.par_iterator_end(); for (; pit != end; ++pit) { -#ifdef WITH_WARNINGS -#warning bogus type (Lgb) -#endif - char const labeltype = pit->layout()->labeltype; - if (labeltype >= LABEL_COUNTER - && labeltype <= LABEL_COUNTER + bufparams.tocdepth) { - // insert this into the table of contents - const int depth = max(0, labeltype - textclass.maxcounter()); - TocItem const item(pit->id(), depth, - pit->asString(buf, true)); + int const toclevel = pit->layout()->toclevel; + if (toclevel > 0 && toclevel <= bufparams.tocdepth) { + // insert this into the table of contents + TocItem const item(pit->id(), toclevel - 1, pit->asString(buf, true)); toclist["TOC"].push_back(item); } -- 2.39.5