+2004-03-31 Angus Leeming <leeming@lyx.org>
+
+ * lyxfunc.C (loadTextclass): new helper function, invoked by two of
+ dispatch's case blocks, LFUN_TEXTCLASS_APPLY and LFUN_TEXTCLASS_LOAD.
+
+ * lyxtextclass.C (load): if the text class couldn't be loaded, then
+ don't overwrite 'loaded_ = false' with 'loaded_ = true' !
+
2004-03-31 Angus Leeming <leeming@lyx.org>
* lyxfunc.C (dispatch): remove the cursor-manipulation code from
return buf.isClean();
}
+
void showPrintError(string const & name)
{
- string str = bformat(_("Could not print the document %1$s.\n"
- "Check that your printer is set up correctly."),
- MakeDisplayPath(name, 50));
- Alert::error(_("Print document failed"), str);
+ string str = bformat(_("Could not print the document %1$s.\n"
+ "Check that your printer is set up correctly."),
+ MakeDisplayPath(name, 50));
+ Alert::error(_("Print document failed"), str);
}
+
+void loadTextclass(string const & name)
+{
+ std::pair<bool, lyx::textclass_type> const tc_pair =
+ textclasslist.NumberOfClass(name);
+
+ if (!tc_pair.first) {
+ lyxerr << "Document class \"" << name
+ << "\" does not exist."
+ << std::endl;
+ return;
+ }
+
+ lyx::textclass_type const tc = tc_pair.second;
+
+ if (!textclasslist[tc].load()) {
+ string s = bformat(_("The document could not be converted\n"
+ "into the document class %1$s."),
+ textclasslist[tc].name());
+ Alert::error(_("Could not change class"), s);
+ }
+}
+
} //namespace anon
lyx::textclass_type const old_class =
buffer->params().textclass;
- dispatch(FuncRequest(LFUN_TEXTCLASS_LOAD, argument));
+ loadTextclass(argument);
std::pair<bool, lyx::textclass_type> const tc_pair =
textclasslist.NumberOfClass(argument);
break;
}
- case LFUN_TEXTCLASS_LOAD: {
- std::pair<bool, lyx::textclass_type> const tc_pair =
- textclasslist.NumberOfClass(argument);
-
- if (!tc_pair.first) {
- lyxerr << "Document class \"" << argument
- << "\" does not exist."
- << std::endl;
- break;
- }
-
- lyx::textclass_type const tc = tc_pair.second;
-
- bool const success = textclasslist[tc].load();
- if (success)
- break;
-
- string s = bformat(_("The document could not be converted\n"
- "into the document class %1$s."),
- textclasslist[tc].name());
- Alert::error(_("Could not change class"), s);
-
+ case LFUN_TEXTCLASS_LOAD:
+ loadTextclass(argument);
break;
- }
default: {
DispatchResult res = view()->cursor().dispatch(cmd);
// Read style-file
string const real_file = LibFileSearch("layouts", name_, "layout");
+ loaded_ = const_cast<LyXTextClass*>(this)->Read(real_file) == 0;
- if (const_cast<LyXTextClass*>(this)->Read(real_file)) {
+ if (!loaded_) {
lyxerr << "Error reading `"
<< MakeDisplayPath(real_file)
<< "'\n(Check `" << name_
<< "')\nCheck your installation and "
"try Options/Reconfigure..." << endl;
- loaded_ = false;
}
- loaded_ = true;
+
return loaded_;
}