]> git.lyx.org Git - features.git/commitdiff
Improve handling of local layout files. There are two bugs here that still need fixin...
authorRichard Heck <rgheck@comcast.net>
Sat, 1 Mar 2008 16:32:16 +0000 (16:32 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 1 Mar 2008 16:32:16 +0000 (16:32 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23372 a592a061-630c-0410-9148-cb99ea01b6c8

src/BaseClassList.cpp
src/BufferParams.cpp
src/frontends/qt4/GuiDocument.cpp

index 1215e66b0dbd88036269e10803f65334f015aae2..35decb3f5dade4b1b117a1198da5b6b1a4198c8f 100644 (file)
@@ -189,23 +189,14 @@ string const BaseClassList::localPrefix = "LOCAL:";
 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;
@@ -231,14 +222,6 @@ LayoutFileIndex
                                // now, create a TextClass with description containing path information
                                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
index 2fba2fb213f675d7ab0c8d3f5388dd21ef071415..7c84bfa21f4d4afb52f41286c7501f85c299cc5c 100644 (file)
@@ -1386,22 +1386,18 @@ void BufferParams::setDocumentClass(DocumentClass const * const tc) {
 
 bool BufferParams::setBaseClass(string const & classname)
 {
-       string localtc = classname;
+       LYXERR(Debug::TCLASS, "setBaseClass: " << classname);
        BaseClassList const & bcl = BaseClassList::get();
-       if (!bcl.haveClass(localtc)) {
-               // OK, let's try again assuming it's a local file
-               localtc = BaseClassList::localPrefix + localtc;
-               if (!bcl.haveClass(localtc)) {
-                       docstring s = 
-                               bformat(_("The document class %1$s could not be found."),
-                               from_utf8(classname));
-                       frontend::Alert::error(_("Class not found"), s);
-                       return false;
-               }
+       if (!bcl.haveClass(classname)) {
+               docstring s = 
+                       bformat(_("The document class %1$s could not be found."),
+                       from_utf8(classname));
+               frontend::Alert::error(_("Class not found"), s);
+               return false;
        }
 
-       if (bcl[localtc].load()) {
-               pimpl_->baseClass_ = localtc;
+       if (bcl[classname].load()) {
+               pimpl_->baseClass_ = classname;
                return true;
        }
        
index e2309bfbef992e9f0cb270a2922f6ef46d2bb5d1..59973edb9f2ffa50448667e1ee65c2f5d09448f1 100644 (file)
@@ -901,9 +901,6 @@ GuiDocument::GuiDocument(GuiView & lv)
                latexModule->psdriverCO->addItem(enc);
        }
        // latex classes
-       //FIXME This seems too involved with the kernel. Some of this
-       //should be moved to the kernel---which should perhaps just
-       //give us a list of entries or something of the sort.
        latexModule->classCO->setModel(&classes_model_);
        BaseClassList const & bcl = BaseClassList::get();
        vector<LayoutFileIndex> classList = bcl.classList();
@@ -916,7 +913,7 @@ GuiDocument::GuiDocument(GuiView & lv)
                docstring item = (tc.isTeXClassAvailable()) ?
                        from_utf8(tc.description()) :
                        bformat(_("Unavailable: %1$s"), from_utf8(tc.description()));
-               classes_model_.insertRow(i, toqstr(item), tc.name());
+               classes_model_.insertRow(i, toqstr(item), *cit);
        }
 
        // branches
@@ -1245,6 +1242,7 @@ void GuiDocument::classChanged()
        if (idx < 0) 
                return;
        string const classname = classes_model_.getIDString(idx);
+       // FIXME There is a bug here: 4594
        if (!bp_.setBaseClass(classname)) {
                Alert::error(_("Error"), _("Unable to set document class."));
                return;
@@ -1832,7 +1830,7 @@ void GuiDocument::updateParams(BufferParams const & params)
        }
 
        // text layout
-       string const & classname = params.baseClass()->name();
+       string const & classname = params.baseClassID();
        int idx = classes_model_.findIDString(classname);
        if (idx < 0)
                lyxerr << "Unable to set layout for classname " << classname << std::endl;