+2000-03-20 José Abílio Matos <jamatos@lyx.org>
+
+ * src/lyxrc.[Ch] Removed \sgml_extra_options, added 6 other flags
+ for linuxdoc and docbook import and export format options.
+
+ * lib/lyxrc.example Example of default values for the previous flags.
+
+ * src/lyx_cb.C Use those flags instead of the hardwired values for
+ linuxdoc and docbook export.
+
+ * src/lyxfunc.[Ch] Added HTML export for linuxdoc and docbook, added
+ linuxdoc import.
+
+ * src/menus.C Added menus entries for the new import/exports formats.
+
2000-03-09 André Pönitz <poenitz@mathematik.tu-chemnitz.de>
* src/lyxrc.*: Added support for running without Gui
# Example: use this to let math be italic with tth.
#\html_command "tth -t -i < '$$FName' > '$$OutName'"
-# If you want to pass extra flags to the LinuxDoc sgml scripts, insert them
-# here.
-# Example: the next line activates iso-latin1 support:
-#\sgml_extra_options -l
-
# Keyboard Mapping. Use this to set the correct mapping file for your
# keyboard, that is if you need one. You'll need one if you for instance
# want to type German documents on an American keyboard. In that case,
#\font_encoding default
+#
+# LINUXDOC SECTION #######################################################
+#
+
+# If you want to pass extra flags to the LinuxDoc sgml scripts, insert them
+# here.
+# Example: the next line activates iso-latin1 support:
+#\linuxdoc_to_latex_command "sgml2latex -c latin"
+
+# Here you have the command to convert from linuxdoc to html.
+# Example: one html file only.
+#\linuxdoc_to_html_command "sgml2html -s 0"
+
+# The LinuxDoc to LyX converter
+#\linuxdoc_to_lyx_command "sgml2lyx"
+
+#
+# DOCBOOK SECTION ########################################################
+#
+
+# Command to convert a docbook file to dvi
+#\docbook_to_dvi_command "sgmltools -b dvi"
+
+# Command to convert a docbook file to html
+#\docbook_to_html_command "sgmltools -b html"
+
+# Command to convert a docbook file to pdf
+#\docbook_to_pdf_command ""
+
+
#
# FILE SECTION ##########################################################
#
#include <config.h>
#include <fstream>
+#include <algorithm>
using std::ifstream;
using std::copy;
}
+void MenuMakeHTML_LinuxDoc(Buffer * buffer)
+{
+ // First, create LinuxDoc file
+ MenuMakeLinuxDoc(buffer);
+
+ // And now, run the converter
+ string file = buffer->fileName();
+
+ string result = ChangeExtension(file, ".html", false);
+ string infile = ChangeExtension(file, ".sgml", false);
+ string tmp = lyxrc.linuxdoc_to_html_command;
+ tmp = subst(tmp, "$$FName", infile);
+ tmp = subst(tmp, "$$OutName", result);
+ Systemcalls one;
+ int res = one.startscript(Systemcalls::System, tmp);
+ if (res == 0) {
+ ShowMessage(buffer,_("Document exported as HTML to file `")
+ + MakeDisplayPath(result) +'\'');
+ } else {
+ ShowMessage(buffer,_("Unable to convert to HTML the file `")
+ + MakeDisplayPath(infile)
+ + '\'');
+ }
+
+}
+
+void MenuMakeHTML_DocBook(Buffer * buffer)
+{
+ // First, create LaTeX file
+ MenuMakeDocBook(buffer);
+
+ // And now, run the converter
+ string file = buffer->fileName();
+ string result = ChangeExtension(file, ".html", false);
+ string infile = ChangeExtension(file, ".sgml", false);
+ string tmp = lyxrc.docbook_to_html_command;
+ tmp = subst(tmp, "$$FName", infile);
+ tmp = subst(tmp, "$$OutName", result);
+ Systemcalls one;
+ int res = one.startscript(Systemcalls::System, tmp);
+ if (res == 0) {
+ ShowMessage(buffer,_("Document exported as HTML to file `")
+ + MakeDisplayPath(result) +'\'');
+ } else {
+ ShowMessage(buffer,_("Unable to convert to HTML the file `")
+ + MakeDisplayPath(infile)
+ + '\'');
+ }
+
+}
+
void MenuExport(Buffer * buffer, string const & extyp)
{
// latex
else if (extyp == "html") {
MenuMakeHTML(buffer);
}
+ // HTML from linuxdoc
+ else if (extyp == "html-linuxdoc") {
+ MenuMakeHTML_LinuxDoc(buffer);
+ }
+ // HTML from docbook
+ else if (extyp == "html-docbook") {
+ MenuMakeHTML_DocBook(buffer);
+ }
else {
ShowMessage(buffer, _("Unknown export type: ") + extyp);
}
switch (flag) {
case 0: /* TeX output asked */
bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
- s2 = "sgml2latex " + add_flags + " -o tex "
- + lyxrc.sgml_extra_options + ' ' + name;
+ s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name;
if (one.startscript(Systemcalls::System, s2))
errorcode = 1;
break;
case 1: /* dvi output asked */
bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
- s2 = "sgml2latex " + add_flags + " -o dvi "
- + lyxrc.sgml_extra_options + ' ' + name;
+ s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
} else
current_view->buffer()->makeDocBookFile(name, 0);
// Shall this code go or should it stay? (Lgb)
+ // This code is a placeholder for future implementation. (Jose')
// string add_flags;
// LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize;
// switch (ps) {
case 1: /* dvi output asked */
{
current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file..."));
- string s2 = "sgmltools --backend dvi " + name;
+ string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
} else
case LFUN_IMPORT:
if (argument == "latex")
disable = lyxrc.relyx_command == "none";
+ if (argument == "linuxdoc")
+ disable = lyxrc.linuxdoc_to_lyx_command == "none";
break;
case LFUN_EXPORT:
if (argument == "dvi" || argument == "postscript")
disable = noLaTeX;
if (argument == "html")
disable = lyxrc.html_command == "none";
+ if (argument == "html-linuxdoc")
+ disable = lyxrc.linuxdoc_to_html_command == "none";
+ if (argument == "html-docbook")
+ disable = lyxrc.docbook_to_html_command == "none";
break;
case LFUN_UNDO:
disable = buf->undostack.empty();
// noweb
} else if (imtyp == "noweb") {
doImportLaTeX(true);
+ } else if (imtyp == "linuxdoc") {
+ doImportLinuxDoc();
} else {
setErrorMessage(string(N_("Unknown import type: "))
+ imtyp);
}
+void LyXFunc::doImportLinuxDoc()
+{
+ string initpath = lyxrc.document_path;
+ LyXFileDlg fileDlg;
+
+ if (owner->view()->available()) {
+ string trypath = owner->buffer()->filepath;
+ // If directory is writeable, use this as default.
+ if (IsDirWriteable(trypath) == 1)
+ initpath = trypath;
+ }
+
+ // launches dialog
+ ProhibitInput();
+ fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
+ fileDlg.SetButton(1, _("Examples"),
+ AddPath(system_lyxdir, "examples"));
+
+ string filename = fileDlg.Select(_("Select LinuxDoc file to Import"),
+ initpath, "*.sgml");
+
+ AllowInput();
+
+ // check selected filename
+ if (filename.empty()) {
+ owner->getMiniBuffer()->Set(_("Canceled."));
+ return;
+ }
+
+ // get absolute path of file
+ filename = MakeAbsPath(filename);
+
+ // Check if the document already is open
+ string LyXfilename = ChangeExtension(filename, ".lyx", false);
+ if (bufferlist.exists(LyXfilename)){
+ switch(AskConfirmation(_("Document is already open:"),
+ MakeDisplayPath(LyXfilename, 50),
+ _("Do you want to close that document now?\n"
+ "('No' will just switch to the open version)")))
+ {
+ case 1: // Yes: close the document
+ if (!bufferlist.close(bufferlist.getBuffer(LyXfilename)))
+ // If close is canceled, we cancel here too.
+ return;
+ break;
+ case 2: // No: switch to the open document
+ owner->view()->buffer(
+ bufferlist.getBuffer(LyXfilename));
+ return;
+ case 3: // Cancel: Do nothing
+ owner->getMiniBuffer()->Set(_("Canceled."));
+ return;
+ }
+ }
+
+ // Check if a LyX document by the same root exists in filesystem
+ FileInfo f(LyXfilename, true);
+ if (f.exist() && !AskQuestion(_("A document by the name"),
+ MakeDisplayPath(LyXfilename),
+ _("already exists. Overwrite?"))) {
+ owner->getMiniBuffer()->Set(_("Canceled."));
+ return;
+ }
+
+ // loads document
+ owner->getMiniBuffer()->Set(_("Importing LinuxDoc file"),
+ MakeDisplayPath(filename), "...");
+
+ // run sgml2lyx
+ string tmp = lyxrc.linuxdoc_to_lyx_command + filename;
+ Systemcalls one;
+ Buffer * buf = 0;
+
+ int result = one.startscript(Systemcalls::System, tmp);
+ if (result == 0) {
+ string filename = ChangeExtension(filename, ".lyx", false);
+ // File was generated without problems. Load it.
+ buf = bufferlist.loadLyXFile(filename);
+ owner->view()->buffer(buf);
+ owner->getMiniBuffer()->Set(_("LinuxDoc file "),
+ MakeDisplayPath(filename),
+ _("imported."));
+ } else {
+ owner->getMiniBuffer()->Set(_("Could not import LinuxDoc file"),
+ MakeDisplayPath(filename));
+ }
+}
+
+
void LyXFunc::MenuInsertLyXFile(string const & filen)
{
string filename = filen;
///
void doImportASCII(bool);
+ ///
+ void doImportLinuxDoc();
+
///
void MenuInsertLyXFile(string const &);
RC_SCREEN_FONT_ENCODING,
RC_SCREEN_FONT_ENCODING_MENU,
RC_AUTOSAVE,
- RC_SGML_EXTRA_OPTIONS,
RC_DOCUMENTPATH,
RC_TEMPLATEPATH,
RC_TEMPDIRPATH,
RC_DATE_INSERT_FORMAT,
RC_SHOW_BANNER,
RC_USE_GUI,
+ RC_LINUXDOC_TO_LYX_COMMAND,
+ RC_LINUXDOC_TO_HTML_COMMAND,
+ RC_LINUXDOC_TO_LATEX_COMMAND,
+ RC_DOCBOOK_TO_DVI_COMMAND,
+ RC_DOCBOOK_TO_HTML_COMMAND,
+ RC_DOCBOOK_TO_PDF_COMMAND,
RC_LAST
};
{ "\\date_insert_format", RC_DATE_INSERT_FORMAT },
{ "\\default_papersize", RC_DEFAULT_PAPERSIZE },
{ "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
+ { "\\docbook_to_dvi_command", RC_DOCBOOK_TO_DVI_COMMAND },
+ { "\\docbook_to_html_command", RC_DOCBOOK_TO_HTML_COMMAND },
+ { "\\docbook_to_pdf_command", RC_DOCBOOK_TO_PDF_COMMAND },
{ "\\document_path", RC_DOCUMENTPATH },
{ "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
{ "\\escape_chars", RC_ESC_CHARS },
{ "\\language_package", RC_LANGUAGE_PACKAGE },
{ "\\lastfiles", RC_LASTFILES },
{ "\\latex_command", RC_LATEX_COMMAND },
+ { "\\linuxdoc_to_html_command", RC_LINUXDOC_TO_HTML_COMMAND },
+ { "\\linuxdoc_to_latex_command", RC_LINUXDOC_TO_LATEX_COMMAND },
+ { "\\linuxdoc_to_lyx_command", RC_LINUXDOC_TO_LYX_COMMAND },
{ "\\literate_command", RC_LITERATE_COMMAND },
{ "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
{ "\\literate_extension", RC_LITERATE_EXTENSION },
{ "\\screen_zoom", RC_SCREEN_ZOOM },
{ "\\selection_color", RC_SELECTION_COLOR },
{ "\\serverpipe", RC_SERVERPIPE },
- { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
{ "\\show_banner", RC_SHOW_BANNER },
{ "\\spell_command", RC_SPELL_COMMAND },
{ "\\tempdir_path", RC_TEMPDIRPATH },
date_insert_format = "%A, %e %B %Y";
show_banner = true;
use_gui = true;
+
+ ///
+ linuxdoc_to_latex_command="none";
+ linuxdoc_to_lyx_command="none";
+ linuxdoc_to_html_command="none";
+
+ docbook_to_dvi_command="none";
+ docbook_to_html_command="none";
+ docbook_to_pdf_command="none";
+
//
defaultKeyBindings();
}
autosave = lexrc.GetInteger();
break;
- case RC_SGML_EXTRA_OPTIONS:
- if (lexrc.next())
- sgml_extra_options = lexrc.GetString();
- break;
-
case RC_DOCUMENTPATH:
if (lexrc.next()) {
document_path = ExpandPath(lexrc.GetString());
if (lexrc.next())
use_gui = lexrc.GetBool();
break;
+ case RC_LINUXDOC_TO_LYX_COMMAND:
+ if ( lexrc.next())
+ linuxdoc_to_lyx_command = lexrc.GetString();
+ break;
+ case RC_LINUXDOC_TO_HTML_COMMAND:
+ if ( lexrc.next())
+ linuxdoc_to_html_command = lexrc.GetString();
+ break;
+ case RC_LINUXDOC_TO_LATEX_COMMAND:
+ if ( lexrc.next())
+ linuxdoc_to_latex_command = lexrc.GetString();
+ break;
+ case RC_DOCBOOK_TO_DVI_COMMAND:
+ if ( lexrc.next())
+ docbook_to_dvi_command = lexrc.GetString();
+ break;
+ case RC_DOCBOOK_TO_HTML_COMMAND:
+ if ( lexrc.next())
+ docbook_to_html_command = lexrc.GetString();
+ break;
+ case RC_DOCBOOK_TO_PDF_COMMAND:
+ if ( lexrc.next())
+ docbook_to_pdf_command = lexrc.GetString();
+ break;
case RC_LAST: break; // this is just a dummy
}
}
os << "\\chktex_command \"" << chktex_command << "\"\n";
case RC_HTML_COMMAND:
os << "\\html_command \"" << html_command << "\"\n";
- case RC_SGML_EXTRA_OPTIONS:
- os << "\\sgml_extra_options \"" << sgml_extra_options
- << "\"\n";
case RC_KBMAP:
os << "\\kbmap " << tostr(use_kbmap) << "\n";
case RC_KBMAP_PRIMARY:
os << "\\show_banner " << tostr(show_banner) << "\n";
case RC_USE_GUI:
os << "\\use_gui " << tostr(show_banner) << "\n";
+ case RC_LINUXDOC_TO_LYX_COMMAND:
+ os << "\\linuxdoc_to_lyx_command \"" << linuxdoc_to_lyx_command
+ << "\"\n";
+ case RC_LINUXDOC_TO_HTML_COMMAND:
+ os << "\\linuxdoc_to_html_command \"" << linuxdoc_to_html_command
+ << "\"\n";
+ case RC_LINUXDOC_TO_LATEX_COMMAND:
+ os << "\\linuxdoc_to_latex_command \"" << linuxdoc_to_latex_command
+ << "\"\n";
+ case RC_DOCBOOK_TO_DVI_COMMAND:
+ os << "\\docbook_to_dvi_command \"" << docbook_to_dvi_command
+ << "\"\n";
+ case RC_DOCBOOK_TO_HTML_COMMAND:
+ os << "\\docbook_to_html_command \"" << docbook_to_html_command
+ << "\"\n";
+ case RC_DOCBOOK_TO_PDF_COMMAND:
+ os << "\\docbook_to_pdf_command \"" << docbook_to_pdf_command
+ << "\"\n";
}
os.flush();
}
/// command to run an html converter incl. options
string html_command;
///
- string sgml_extra_options;
- ///
string document_path;
///
string template_path;
/// Do we have to use a GUI?
bool use_gui;
///
+ string linuxdoc_to_lyx_command;
+ ///
+ string linuxdoc_to_html_command;
+ ///
+ string linuxdoc_to_latex_command;
+ ///
+ string docbook_to_dvi_command;
+ ///
+ string docbook_to_html_command;
+ ///
+ string docbook_to_pdf_command;
+ ///
typedef map<string, int> Bindings;
///
Bindings bindings;
"|LaTeX...%x30"
"|Ascii Text as Lines...%x31"
"|Ascii Text as Paragraphs%x32"
- "|Noweb%x33"));
-
+ "|Noweb%x33"
+ "|LinuxDoc%x34"));
+
fl_setpup_shortcut(SubFileImport, 30, scex(_("FIM|Ll#l#L")));
fl_setpup_shortcut(SubFileImport, 31, scex(_("FIM|Aa#a#A")));
fl_setpup_shortcut(SubFileImport, 32, scex(_("FIM|Pp#p#P")));
fl_setpup_shortcut(SubFileImport, 33, scex(_("FIM|Nn#n#N")));
+ fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
// Export sub-menu
"|as LinuxDoc...%x40"
"|as DVI...%x41"
"|as PostScript...%x42"
- "|as Ascii Text...%x43"));
+ "|as Ascii Text...%x43"
+ "|as HTML...%x44"));
else if(DocBook)
SubFileExport= fl_defpup(FL_ObjWin(ob),
_("Export%t"
"|as DocBook...%x40"
"|as DVI...%x41"
"|as PostScript...%x42"
- "|as Ascii Text...%x43"));
+ "|as Ascii Text...%x43"
+ "|as HTML...%x44"));
fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
fl_setpup_shortcut(SubFileExport, 43, scex(_("FEX|Tt#t#T")));
+ fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
+
if (!LinuxDoc && !DocBook) {
- fl_setpup_shortcut(SubFileExport, 44, scex(_("FEX|Hh#h#H")));
fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
}
fl_setpup_mode(SubFileImport, 33, FL_PUP_GREY);
}
+ if ( lyxrc.linuxdoc_to_lyx_command == "none")
+ fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
+
if (!hasLaTeX) {
// Disable export dvi and export postscript
fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
fl_setpup_mode(SubFileExport, 42, FL_PUP_GREY);
}
- if (lyxrc.html_command == "none") {
+ if ((!LinuxDoc && !DocBook && lyxrc.html_command == "none") ||
+ ( LinuxDoc && lyxrc.linuxdoc_to_html_command == "none") ||
+ ( DocBook && lyxrc.docbook_to_html_command == "none")) {
// Disable export HTML
fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
}
break;
case 33: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
break;
+ case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
+ break;
case 16: // export menu
case 40:
if (!LinuxDoc && !DocBook)
break;
case 43: tmpfunc->Dispatch(LFUN_EXPORT, "ascii");
break;
- case 44: tmpfunc->Dispatch(LFUN_EXPORT, "html");
+ case 44:
+ if (!LinuxDoc && !DocBook)
+ tmpfunc->Dispatch(LFUN_EXPORT, "html");
+ else if(LinuxDoc)
+ tmpfunc->Dispatch(LFUN_EXPORT, "html-linuxdoc");
+ else
+ tmpfunc->Dispatch(LFUN_EXPORT, "html-docbook");
break;
case 45: tmpfunc->Dispatch(LFUN_EXPORT, "custom");
break;
"|LaTeX...%x15"
"|Ascii Text as Lines...%x16"
"|Ascii Text as Paragraphs...%x17"
- "|Noweb...%x18"));
+ "|Noweb...%x18"
+ "|LinuxDoc...%x19"));
fl_setpup_shortcut(SubFileImport, 15, scex(_("FIM|Ll#l#L")));
fl_setpup_shortcut(SubFileImport, 16, scex(_("FIM|Aa#a#A")));
fl_setpup_shortcut(SubFileImport, 17, scex(_("FIM|Pp#p#P")));
fl_setpup_shortcut(SubFileImport, 18, scex(_("FIM|Nn#n#N")));
+ fl_setpup_shortcut(SubFileImport, 19, scex(_("FIM|Dd#d#D")));
bool hasReLyX = lyxrc.relyx_command != "none";
if (!hasReLyX) {
fl_setpup_mode(SubFileImport, 18, FL_PUP_GREY);
}
+ if ( lyxrc.linuxdoc_to_lyx_command == "none")
+ fl_setpup_mode(SubFileImport, 19, FL_PUP_GREY);
+
// This can be done cleaner later.
int FileMenu = fl_defpup(FL_ObjWin(ob),
_("New..."
break;
case 18: tmpfunc->Dispatch(LFUN_IMPORT, "noweb");
break;
+ case 19: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
+ break;
case 5:
tmpfunc->Dispatch(LFUN_QUIT);
break;