]> git.lyx.org Git - lyx.git/blobdiff - src/BaseClassList.cpp
* is.at is const, is[] is a deep non-const copy
[lyx.git] / src / BaseClassList.cpp
index 5fd88b958267fbc818cc11db9e53109efee0354c..35decb3f5dade4b1b117a1198da5b6b1a4198c8f 100644 (file)
 #include <config.h>
 
 #include "BaseClassList.h"
-#include "TextClass.h"
+#include "Counters.h"
+#include "Floating.h"
+#include "FloatList.h"
 #include "Lexer.h"
+#include "TextClass.h"
 
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
+#include "support/gettext.h"
 
 #include <boost/bind.hpp>
 #include <boost/regex.hpp>
@@ -33,6 +37,16 @@ using boost::bind;
 using boost::regex;
 using boost::smatch;
 
+LayoutFile::LayoutFile(string const & fn, string const & cln,
+                          string const & desc, bool texClassAvail )
+{
+       name_ = fn;
+       latexname_ = cln;
+       description_ = desc;
+       texClassAvail_ = texClassAvail;
+}
+
+
 BaseClassList & BaseClassList::get() 
 {
        static BaseClassList baseclasslist;
@@ -52,9 +66,15 @@ bool BaseClassList::haveClass(string const & classname) const
 }
 
 
-// Gets a textclass structure from string
-TextClass const & 
-       BaseClassList::operator[](string const & classname) const
+LayoutFile const & BaseClassList::operator[](string const & classname) const
+{
+       BOOST_ASSERT(haveClass(classname));
+       return classmap_[classname];
+}
+
+
+LayoutFile & 
+       BaseClassList::operator[](string const & classname)
 {
        BOOST_ASSERT(haveClass(classname));
        return classmap_[classname];
@@ -119,7 +139,7 @@ bool BaseClassList::read()
                                                LYXERR(Debug::TCLASS, "Avail: " << avail);
                                                // This code is run when we have
                                                // fname, clname, desc, and avail
-                                               TextClass tmpl(fname, clname, desc, avail);
+                                               LayoutFile tmpl(fname, clname, desc, avail);
                                                if (lyxerr.debugging(Debug::TCLASS)) {
                                                        // only system layout files are loaded here so no
                                                        // buffer path is needed.
@@ -143,9 +163,9 @@ bool BaseClassList::read()
 }
 
 
-std::vector<BaseClassIndex> BaseClassList::classList() const
+std::vector<LayoutFileIndex> BaseClassList::classList() const
 {
-       std::vector<BaseClassIndex> cl;
+       std::vector<LayoutFileIndex> cl;
        ClassMap::const_iterator it = classmap_.begin();
        ClassMap::const_iterator en = classmap_.end();
        for (; it != en; ++it)
@@ -154,10 +174,10 @@ std::vector<BaseClassIndex> BaseClassList::classList() const
 }
 
 
-void BaseClassList::reset(BaseClassIndex const & classname) {
+void BaseClassList::reset(LayoutFileIndex const & classname) {
        BOOST_ASSERT(haveClass(classname));
-       TextClass const & tc = classmap_[classname];
-       TextClass tmpl(tc.name(), tc.latexname(), tc.description(), 
+       LayoutFile const & tc = classmap_[classname];
+       LayoutFile tmpl(tc.name(), tc.latexname(), tc.description(),
                       tc.isTeXClassAvailable());
        classmap_[classname] = tmpl;
 }
@@ -166,26 +186,17 @@ void BaseClassList::reset(BaseClassIndex const & classname) {
 string const BaseClassList::localPrefix = "LOCAL:";
 
 
-BaseClassIndex 
-       BaseClassList::addTextClass(string const & textclass, string const & path)
+LayoutFileIndex 
+       BaseClassList::addLayoutFile(string const & textclass, string const & path)
 {
-       // FIXME BUGS
-       // There be bugs here. The way this presently works, the local class gets 
-       // added to the global list of available document classes. It will then
-       // appear on the list in Document>Settings, where it could be chosen in, 
-       // say, a new document, with no real warning that the class may not be
-       // available when the document is saved, since the new document may not be
-       // in the same directory as the layout file.
-       //
-       // Another bug is this: If the Document>Settings dialog is open when a file
-       // with a local layout is opened, the dialog doesn't update.
+       // FIXME  There is a bug here: 4593
        //
        // only check for textclass.layout file, .cls can be anywhere in $TEXINPUTS
        // NOTE: latex class name is defined in textclass.layout, which can be 
        // different from textclass
        string fullName = addName(path, textclass + ".layout");
-       string localIndex = localPrefix + textclass;
-
+       string localIndex = localPrefix + fullName;
+       
        // if the local file has already been loaded, return it
        if (haveClass(localIndex))
                return localIndex;
@@ -209,16 +220,8 @@ BaseClassIndex
                                // returns: whole string, classtype (not used here), class name, description
                                BOOST_ASSERT(sub.size() == 4);
                                // now, create a TextClass with description containing path information
-                               TextClass tmpl(textclass, sub.str(2) == "" ? textclass : sub.str(2),
+                               LayoutFile tmpl(textclass, sub.str(2) == "" ? textclass : sub.str(2),
                                        sub.str(3) + " <" + path + ">", true);
-                               // Do not add this local TextClass to classmap_ if it has
-                               // already been loaded by, for example, a master buffer.
-                               if (haveClass(textclass)
-                                               // FIXME I don't understand this comment (rgh)
-                                               // only layouts from the same directory are considered to be identical.
-                                               && classmap_[textclass].description() == tmpl.description()
-                                  )
-                                       return textclass;
                                classmap_[localIndex] = tmpl;
                                // This textclass is added on request so it will definitely be
                                // used. Load it now because other load() calls may fail if they
@@ -233,7 +236,7 @@ BaseClassIndex
 }
 
 
-BaseClassIndex defaultBaseclass()
+LayoutFileIndex defaultBaseclass()
 {
        if (BaseClassList::get().haveClass("article"))
                return string("article");