+
+void Buffer::Dispatch(const string & command)
+{
+ // Split command string into command and argument
+ string cmd, line = frontStrip(command);
+ string arg = strip(frontStrip(split(line, cmd, ' ')));
+
+ Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
+}
+
+void Buffer::Dispatch(int action, const string & argument)
+{
+ switch (action) {
+ case LFUN_EXPORT: {
+ // latex
+ if (argument == "latex") {
+ // make sure that this buffer is not linuxdoc
+ MenuMakeLaTeX(this);
+ }
+ // linuxdoc
+ else if (argument == "linuxdoc") {
+ // make sure that this buffer is not latex
+ MenuMakeLinuxDoc(this);
+ }
+ // docbook
+ else if (argument == "docbook") {
+ // make sure that this buffer is not latex or linuxdoc
+ MenuMakeDocBook(this);
+ }
+ // dvi
+ else if (argument == "dvi") {
+ // Run LaTeX as "Update dvi..." Bernhard.
+ // We want the dvi in the current directory. This
+ // is achieved by temporarily disabling use of
+ // temp directory. As a side-effect, we get
+ // *.log and *.aux files also. (Asger)
+ bool flag = lyxrc->use_tempdir;
+ lyxrc->use_tempdir = false;
+ MenuRunLaTeX(this);
+ lyxrc->use_tempdir = flag;
+ }
+ // postscript
+ else if (argument == "postscript") {
+ // Start Print-dialog. Not as good as dvi... Bernhard.
+ MenuPrint(this);
+ // Since the MenuPrint is a pop-up, we can't use
+ // the same trick as above. (Asger)
+ // MISSING: Move of ps-file :-|
+ }
+ // ascii
+ else if (argument == "ascii") {
+ MenuMakeAscii(this);
+ }
+ else if (argument == "custom") {
+ MenuSendto();
+ break;
+ }
+ // HTML
+ else if (argument == "html" && lyxrc->html_command != "none") {
+ // First, create LaTeX file
+ MenuMakeLaTeX(this);
+
+ // And now, run the converter
+ string file = fileName();
+ Path path(OnlyPath(file));
+ // the tex file name has to be correct for
+ // latex, but the html file name can be
+ // anything.
+ string result = ChangeExtension(file, ".html", false);
+ file = ChangeExtension(MakeLatexName(file), ".tex", false);
+ string tmp = lyxrc->html_command;
+ tmp = subst(tmp, "$$FName", file);
+ tmp = subst(tmp, "$$OutName", result);
+ Systemcalls one;
+ /*int res = */ one.startscript(Systemcalls::System, tmp);
+ //
+ // Hi, Asger. This time I plead guilty and I promise to clean it up
+ //
+ // if (res == 0) {
+ // setMessage(N_("Document exported as HTML to file `")
+ // + MakeDisplayPath(result) +'\ '');
+ // } else {
+ // setErrorMessage(N_("Unable to convert to HTML the file `")
+ // + MakeDisplayPath(file)
+ // + '\'');
+ // }
+ }
+ else {
+ // setErrorMessage(N_("Unknown export type: ")
+ // + argument);
+ }
+ }
+ break;
+
+ default:
+ lyxerr << "A truly unknown func!" << endl;
+ break;
+
+ } // end of switch
+
+}