Load local textclass in addTextClass(), reload local layout correctly in LFUN_TEXTCLASS_APPLY and LFUN_TEXTCLASS_LOAD

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23175 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bo Peng 2008-02-24 06:14:48 +00:00
parent 3c07aff8ef
commit 1aaa96e6f1
3 changed files with 12 additions and 4 deletions

View File

@ -712,7 +712,7 @@ void showPrintError(string const & name)
}
void loadTextClass(string const & name)
void loadTextClass(string const & name, string const & buf_path)
{
pair<bool, TextClassIndex> const tc_pair =
textclasslist.numberOfClass(name);
@ -726,7 +726,7 @@ void loadTextClass(string const & name)
TextClassIndex const tc = tc_pair.second;
if (!textclasslist[tc].load()) {
if (!textclasslist[tc].load(buf_path)) {
docstring s = bformat(_("The document class %1$s."
"could not be loaded."),
from_utf8(textclasslist[tc].name()));
@ -1605,7 +1605,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
BOOST_ASSERT(lyx_view_);
Buffer * buffer = lyx_view_->buffer();
loadTextClass(argument);
loadTextClass(argument, buffer->filePath());
pair<bool, TextClassIndex> const tc_pair =
textclasslist.numberOfClass(argument);
@ -1644,7 +1644,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
}
case LFUN_TEXTCLASS_LOAD:
loadTextClass(argument);
loadTextClass(argument, lyx_view_->buffer()->filePath());
break;
case LFUN_LYXRC_APPLY: {

View File

@ -1010,6 +1010,8 @@ string const & TextClass::name() const
string const & TextClass::latexname() const
{
// No buffer path information is needed here because on-demand layout files
// have already been loaded, and no path is needed for system layouts.
const_cast<TextClass*>(this)->load();
return latexname_;
}

View File

@ -151,6 +151,8 @@ bool TextClassList::read()
// fname, clname, desc, and avail
TextClass tmpl(fname, clname, desc, avail);
if (lyxerr.debugging(Debug::TCLASS)) {
// only system layout files are loaded here so no
// buffer path is needed.
tmpl.load();
}
classlist_.push_back(tmpl);
@ -221,6 +223,10 @@ TextClassList::addTextClass(string const & textclass, string const & path)
if (pp.first && classlist_[pp.second].description() == tmpl.description())
return pp;
classlist_.push_back(tmpl);
// This textclass is added on request so it will definitely be
// used. Load it now because other load() calls may fail if they
// are called in a context without buffer path information.
classlist_.back().load(path);
return make_pair(true, classlist_.size() - 1);
}
}