]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.C
remove unused code
[lyx.git] / src / LaTeXFeatures.C
index 4f22c9fcd46a6c588580f8eeb33196524d58af88..143bbdfa3876918b470c9df533cfc1ad9b021f54 100644 (file)
@@ -19,7 +19,6 @@
 #include "lyx_sty.h"
 #include "lyxrc.h"
 #include "bufferparams.h"
-#include "lyxtextclasslist.h"
 #include "FloatList.h"
 #include "language.h"
 #include "encoding.h"
@@ -31,8 +30,8 @@
 using lyx::textclass_type;
 
 using std::endl;
+using std::list;
 using std::set;
-using std::vector;
 using std::find;
 using std::ostream;
 
@@ -51,9 +50,42 @@ void LaTeXFeatures::require(string const & name)
 }
 
 
-void LaTeXFeatures::useLayout(string const & lyt)
+void LaTeXFeatures::useLayout(string const & layoutname)
 {
-       layout.insert(lyt);
+       // Some code to avoid loops in dependency definition
+       static int level = 0;
+       const int maxlevel = 30;
+       if (level > maxlevel) {
+               lyxerr << "LaTeXFeatures::useLayout: maximum level of "
+                      << "recursion attained by layout "
+                      << layoutname << endl;
+               return;
+       }
+       
+       LyXTextClass tclass = params.getLyXTextClass();
+       if (tclass.hasLayout(layoutname)) {
+               // Is this layout already in usedLayouts?
+               list<string>::const_iterator cit = usedLayouts.begin();
+               list<string>::const_iterator end = usedLayouts.end();
+               for (; cit != end; ++cit) {
+                       if (layoutname == *cit)
+                               return;
+               }
+               
+               LyXLayout_ptr lyt = tclass[layoutname];
+               if (!lyt->depends_on().empty()) {
+                       ++level;
+                       useLayout(lyt->depends_on());
+                       --level;
+               }
+               usedLayouts.push_back(layoutname);
+       } else {
+               lyxerr << "LaTeXFeatures::useLayout: layout `"
+                      << layoutname << "' does not exist in this class"
+                      << endl; 
+       }
+       
+       --level;
 }
 
 
@@ -152,7 +184,7 @@ const int nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
 string const LaTeXFeatures::getPackages() const
 {
        ostringstream packages;
-       LyXTextClass const & tclass = textclasslist[params.textclass];
+       LyXTextClass const & tclass = params.getLyXTextClass();
 
 
        //
@@ -332,13 +364,13 @@ string const LaTeXFeatures::getBabelOptions() const
 string const LaTeXFeatures::getTClassPreamble() const
 {
        // the text class specific preamble
-       LyXTextClass const & tclass = textclasslist[params.textclass];
+       LyXTextClass const & tclass = params.getLyXTextClass();
        ostringstream tcpreamble;
 
        tcpreamble << tclass.preamble();
 
-       set<string>::const_iterator cit = layout.begin();
-       set<string>::const_iterator end = layout.end();
+       list<string>::const_iterator cit = usedLayouts.begin();
+       list<string>::const_iterator end = usedLayouts.end();
        for (; cit != end; ++cit) {
                tcpreamble << tclass[*cit]->preamble();
        }