mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
the export patch from Dekel
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@991 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5f3c7736a2
commit
9625f5e230
38
ChangeLog
38
ChangeLog
@ -1,3 +1,41 @@
|
|||||||
|
2000-08-30 Dekel Tsur <dekel@math.tau.ac.il>
|
||||||
|
|
||||||
|
* src/converter.[Ch]: New file for converting between different
|
||||||
|
formats.
|
||||||
|
|
||||||
|
* src/export.[Ch]: New file for exporting a LyX file to different
|
||||||
|
formats.
|
||||||
|
|
||||||
|
* src/lyx_cb.C: Remove many functions when NEW_EXPORT is defined:
|
||||||
|
MenuRunLaTeX, MakeLaTeXOutput, RunScript, CreatePostscript,
|
||||||
|
PreviewPostscript, PreviewDVI, AskOverwrite, MenuMakeLaTeX,
|
||||||
|
MenuMakeLinuxDoc, MenuMakeDocBook, MenuMakeHTML,
|
||||||
|
MenuMakeHTML_LinuxDoc, MenuMakeHTML_DocBook, RunLinuxDoc,
|
||||||
|
RunDocBook, MenuExport.
|
||||||
|
|
||||||
|
* src/lyxfunc.C (Dispatch): Use the Exporter::Export and
|
||||||
|
Exporter::Preview methods if NEW_EXPORT is defined.
|
||||||
|
|
||||||
|
* src/buffer.C (Dispatch): Use Exporter::Export.
|
||||||
|
|
||||||
|
* src/lyxrc.C: Added new tags: \converter and \viewer.
|
||||||
|
|
||||||
|
* src/commandtags.h
|
||||||
|
* src/LyXAction.C: Define new lyx-function: buffer-update.
|
||||||
|
Remove obsolete buffer-typeset,buffer-typeset-ps & buffer-view-ps
|
||||||
|
when NEW_EXPORT is defined.
|
||||||
|
|
||||||
|
* src/MenuBackend.C: Added new tags: updateformats and viewformats.
|
||||||
|
|
||||||
|
* src/frontends/xforms/Menubar_pimpl.C (add_formats) New method.
|
||||||
|
|
||||||
|
* lib/ui/default.ui: Added submenus "view" and "update" to the
|
||||||
|
"file" menu.
|
||||||
|
|
||||||
|
* src/filetools.C (GetExtension): New function.
|
||||||
|
|
||||||
|
* src/LaTeX.C (LaTeX): Add "-pdf" to depfile if pdflatex is used.
|
||||||
|
|
||||||
2000-08-29 Allan Rae <rae@lyx.org>
|
2000-08-29 Allan Rae <rae@lyx.org>
|
||||||
|
|
||||||
* lib/bind/xemacs.bind: update a binding due to Juergen's recent work
|
* lib/bind/xemacs.bind: update a binding due to Juergen's recent work
|
||||||
|
@ -34,8 +34,10 @@ Menuset
|
|||||||
Separator
|
Separator
|
||||||
Item "View dvi|d" "buffer-view"
|
Item "View dvi|d" "buffer-view"
|
||||||
Item "View Postscript|w" "buffer-view-ps"
|
Item "View Postscript|w" "buffer-view-ps"
|
||||||
|
Submenu "View" "view"
|
||||||
Item "Update dvi|v" "buffer-typeset"
|
Item "Update dvi|v" "buffer-typeset"
|
||||||
Item "Update Postscript|U" "buffer-typeset-ps"
|
Item "Update Postscript|U" "buffer-typeset-ps"
|
||||||
|
Submenu "Update" "update"
|
||||||
OptItem "Build program|B" "build-program"
|
OptItem "Build program|B" "build-program"
|
||||||
Separator
|
Separator
|
||||||
Item "Print...|P" "buffer-print"
|
Item "Print...|P" "buffer-print"
|
||||||
@ -60,6 +62,14 @@ Menuset
|
|||||||
Lastfiles
|
Lastfiles
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Menu "view"
|
||||||
|
ViewFormats
|
||||||
|
End
|
||||||
|
|
||||||
|
Menu "update"
|
||||||
|
UpdateFormats
|
||||||
|
End
|
||||||
|
|
||||||
Menu "import"
|
Menu "import"
|
||||||
Item "LaTeX|L" "buffer-import latex"
|
Item "LaTeX|L" "buffer-import latex"
|
||||||
Item "Ascii text as lines|A" "buffer-import ascii"
|
Item "Ascii text as lines|A" "buffer-import ascii"
|
||||||
@ -68,6 +78,7 @@ Menuset
|
|||||||
End
|
End
|
||||||
|
|
||||||
Menu "export"
|
Menu "export"
|
||||||
|
ExportFormats
|
||||||
OptItem "as LaTeX|L" "buffer-export latex"
|
OptItem "as LaTeX|L" "buffer-export latex"
|
||||||
OptItem "as LinuxDoc|L" "buffer-export linuxdoc"
|
OptItem "as LinuxDoc|L" "buffer-export linuxdoc"
|
||||||
OptItem "as DocBook|B" "buffer-export docbook"
|
OptItem "as DocBook|B" "buffer-export docbook"
|
||||||
|
@ -71,6 +71,8 @@ LaTeX::LaTeX(string const & latex, string const & f, string const & p)
|
|||||||
{
|
{
|
||||||
num_errors = 0;
|
num_errors = 0;
|
||||||
depfile = file + ".dep";
|
depfile = file + ".dep";
|
||||||
|
if (prefixIs(cmd, "pdf")) // Do we use pdflatex ?
|
||||||
|
depfile += "-pdf";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,6 +149,10 @@ void LyXAction::init()
|
|||||||
N_("Switch to an open document"), ReadOnly },
|
N_("Switch to an open document"), ReadOnly },
|
||||||
{ LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
|
{ LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only",
|
||||||
N_("Toggle read-only"), ReadOnly },
|
N_("Toggle read-only"), ReadOnly },
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
{ LFUN_UPDATE, "buffer-update", N_("Update"), ReadOnly },
|
||||||
|
{ LFUN_PREVIEW, "buffer-view", N_("View") , ReadOnly },
|
||||||
|
#else
|
||||||
{ LFUN_RUNLATEX, "buffer-typeset", N_("Update DVI"),
|
{ LFUN_RUNLATEX, "buffer-typeset", N_("Update DVI"),
|
||||||
ReadOnly },
|
ReadOnly },
|
||||||
{ LFUN_RUNDVIPS, "buffer-typeset-ps",
|
{ LFUN_RUNDVIPS, "buffer-typeset-ps",
|
||||||
@ -156,6 +160,7 @@ void LyXAction::init()
|
|||||||
{ LFUN_PREVIEW, "buffer-view", N_("View DVI") , ReadOnly },
|
{ LFUN_PREVIEW, "buffer-view", N_("View DVI") , ReadOnly },
|
||||||
{ LFUN_PREVIEWPS, "buffer-view-ps",
|
{ LFUN_PREVIEWPS, "buffer-view-ps",
|
||||||
N_("View PostScript") , ReadOnly },
|
N_("View PostScript") , ReadOnly },
|
||||||
|
#endif
|
||||||
{ LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly },
|
{ LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly },
|
||||||
{ LFUN_MENUWRITEAS, "buffer-write-as", N_("Save As"),
|
{ LFUN_MENUWRITEAS, "buffer-write-as", N_("Save As"),
|
||||||
ReadOnly },
|
ReadOnly },
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
//#include "lyx_cb.h"
|
//#include "lyx_cb.h"
|
||||||
#include "bufferview_funcs.h"
|
#include "bufferview_funcs.h"
|
||||||
|
#include "exporter.h"
|
||||||
|
|
||||||
extern FD_form_sendto * fd_form_sendto;
|
extern FD_form_sendto * fd_form_sendto;
|
||||||
extern BufferView * current_view;
|
extern BufferView * current_view;
|
||||||
@ -56,6 +57,7 @@ void SendtoApplyCB(FL_OBJECT *, long)
|
|||||||
if (command.empty())
|
if (command.empty())
|
||||||
return;
|
return;
|
||||||
Buffer * buffer = current_view->buffer();
|
Buffer * buffer = current_view->buffer();
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
if (fl_get_button(fd_form_sendto->radio_ftype_dvi) ||
|
if (fl_get_button(fd_form_sendto->radio_ftype_dvi) ||
|
||||||
fl_get_button(fd_form_sendto->radio_ftype_ps)) {
|
fl_get_button(fd_form_sendto->radio_ftype_ps)) {
|
||||||
ProhibitInput(current_view);
|
ProhibitInput(current_view);
|
||||||
@ -66,6 +68,7 @@ void SendtoApplyCB(FL_OBJECT *, long)
|
|||||||
}
|
}
|
||||||
AllowInput(current_view);
|
AllowInput(current_view);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
string ftypeext;
|
string ftypeext;
|
||||||
if (fl_get_button(fd_form_sendto->radio_ftype_lyx))
|
if (fl_get_button(fd_form_sendto->radio_ftype_lyx))
|
||||||
ftypeext = ".lyx";
|
ftypeext = ".lyx";
|
||||||
@ -76,10 +79,16 @@ void SendtoApplyCB(FL_OBJECT *, long)
|
|||||||
else if (fl_get_button(fd_form_sendto->radio_ftype_ascii))
|
else if (fl_get_button(fd_form_sendto->radio_ftype_ascii))
|
||||||
ftypeext = ".txt";
|
ftypeext = ".txt";
|
||||||
else {
|
else {
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
ftypeext = ".ps";
|
||||||
|
if (!Exporter::Export(buffer, "ps", true))
|
||||||
|
return;
|
||||||
|
#else
|
||||||
ftypeext = ".ps_tmp";
|
ftypeext = ".ps_tmp";
|
||||||
if (!CreatePostscript(buffer, true)) {
|
if (!CreatePostscript(buffer, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
string fname = OnlyFilename(ChangeExtension(buffer->getLatexName(),
|
string fname = OnlyFilename(ChangeExtension(buffer->getLatexName(),
|
||||||
|
@ -109,6 +109,8 @@ lyx_SOURCES = \
|
|||||||
combox.h \
|
combox.h \
|
||||||
commandtags.h \
|
commandtags.h \
|
||||||
config.h.in \
|
config.h.in \
|
||||||
|
converter.C \
|
||||||
|
converter.h \
|
||||||
counters.C \
|
counters.C \
|
||||||
counters.h \
|
counters.h \
|
||||||
credits.C \
|
credits.C \
|
||||||
@ -119,6 +121,8 @@ lyx_SOURCES = \
|
|||||||
debug.h \
|
debug.h \
|
||||||
encoding.C \
|
encoding.C \
|
||||||
encoding.h \
|
encoding.h \
|
||||||
|
exporter.C \
|
||||||
|
exporter.h \
|
||||||
ext_l10n.h \
|
ext_l10n.h \
|
||||||
figure.h \
|
figure.h \
|
||||||
filedlg.C \
|
filedlg.C \
|
||||||
|
@ -38,6 +38,9 @@ MenuItem::MenuItem(Kind kind, string const & label,
|
|||||||
case Separator:
|
case Separator:
|
||||||
case Documents:
|
case Documents:
|
||||||
case Lastfiles:
|
case Lastfiles:
|
||||||
|
case ViewFormats:
|
||||||
|
case UpdateFormats:
|
||||||
|
case ExportFormats:
|
||||||
break;
|
break;
|
||||||
case Command:
|
case Command:
|
||||||
action_ = lyxaction.LookupFunc(command);
|
action_ = lyxaction.LookupFunc(command);
|
||||||
@ -70,21 +73,27 @@ Menu & Menu::read(LyXLex & lex)
|
|||||||
md_item = 1,
|
md_item = 1,
|
||||||
md_documents,
|
md_documents,
|
||||||
md_endmenu,
|
md_endmenu,
|
||||||
|
md_exportformats,
|
||||||
md_lastfiles,
|
md_lastfiles,
|
||||||
md_optitem,
|
md_optitem,
|
||||||
md_submenu,
|
md_submenu,
|
||||||
md_separator,
|
md_separator,
|
||||||
|
md_updateformats,
|
||||||
|
md_viewformats,
|
||||||
md_last
|
md_last
|
||||||
};
|
};
|
||||||
|
|
||||||
struct keyword_item menutags[md_last-1] = {
|
struct keyword_item menutags[md_last-1] = {
|
||||||
{ "documents", md_documents },
|
{ "documents", md_documents },
|
||||||
{ "end", md_endmenu },
|
{ "end", md_endmenu },
|
||||||
|
{ "exportformats", md_exportformats },
|
||||||
{ "item", md_item },
|
{ "item", md_item },
|
||||||
{ "lastfiles", md_lastfiles },
|
{ "lastfiles", md_lastfiles },
|
||||||
{ "optitem", md_optitem },
|
{ "optitem", md_optitem },
|
||||||
{ "separator", md_separator },
|
{ "separator", md_separator },
|
||||||
{ "submenu", md_submenu }
|
{ "submenu", md_submenu },
|
||||||
|
{ "updateformats", md_updateformats },
|
||||||
|
{ "viewformats", md_viewformats }
|
||||||
};
|
};
|
||||||
|
|
||||||
lex.pushTable(menutags, md_last - 1);
|
lex.pushTable(menutags, md_last - 1);
|
||||||
@ -120,6 +129,15 @@ Menu & Menu::read(LyXLex & lex)
|
|||||||
case md_documents:
|
case md_documents:
|
||||||
add(MenuItem(MenuItem::Documents));
|
add(MenuItem(MenuItem::Documents));
|
||||||
break;
|
break;
|
||||||
|
case md_viewformats:
|
||||||
|
add(MenuItem(MenuItem::ViewFormats));
|
||||||
|
break;
|
||||||
|
case md_updateformats:
|
||||||
|
add(MenuItem(MenuItem::UpdateFormats));
|
||||||
|
break;
|
||||||
|
case md_exportformats:
|
||||||
|
add(MenuItem(MenuItem::ExportFormats));
|
||||||
|
break;
|
||||||
case md_submenu: {
|
case md_submenu: {
|
||||||
lex.next();
|
lex.next();
|
||||||
char * tmp = strdup(lex.GetString().c_str());
|
char * tmp = strdup(lex.GetString().c_str());
|
||||||
|
@ -40,7 +40,16 @@ public:
|
|||||||
Lastfiles,
|
Lastfiles,
|
||||||
/** This is the list of opened Documents,
|
/** This is the list of opened Documents,
|
||||||
typically for the Documents menu. */
|
typically for the Documents menu. */
|
||||||
Documents
|
Documents,
|
||||||
|
/** This is a list of viewable formats
|
||||||
|
typically for the Documents menu. */
|
||||||
|
ViewFormats,
|
||||||
|
/** This is a list of updatable formats
|
||||||
|
typically for the Documents menu. */
|
||||||
|
UpdateFormats,
|
||||||
|
/** This is a list of exportable formats
|
||||||
|
typically for the Documents menu. */
|
||||||
|
ExportFormats
|
||||||
};
|
};
|
||||||
/// Create a Command type MenuItem
|
/// Create a Command type MenuItem
|
||||||
MenuItem(Kind kind,
|
MenuItem(Kind kind,
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "LyXView.h"
|
#include "LyXView.h"
|
||||||
#include "lyxfunc.h"
|
#include "lyxfunc.h"
|
||||||
|
|
||||||
|
#if FL_REVISION < 89
|
||||||
#include "lyxlookup.h"
|
#include "lyxlookup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
@ -319,7 +322,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
break;
|
break;
|
||||||
case FL_KEYBOARD:
|
case FL_KEYBOARD:
|
||||||
{
|
{
|
||||||
lyxerr[Debug::KEY] << "Workarea event: KEYBOARD";
|
lyxerr[Debug::KEY] << "Workarea event: KEYBOARD" << endl;
|
||||||
|
|
||||||
KeySym keysym = 0;
|
KeySym keysym = 0;
|
||||||
char dummy[1];
|
char dummy[1];
|
||||||
@ -352,6 +355,8 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
|
|||||||
}
|
}
|
||||||
KeySym ret_key = keysym;
|
KeySym ret_key = keysym;
|
||||||
#else
|
#else
|
||||||
|
// Ok, this is a bit simplistic...seems that the rules
|
||||||
|
// need to be a bit more...
|
||||||
if (!key) break;
|
if (!key) break;
|
||||||
KeySym ret_key = (keysym ? keysym : key);
|
KeySym ret_key = (keysym ? keysym : key);
|
||||||
#endif
|
#endif
|
||||||
|
10
src/buffer.C
10
src/buffer.C
@ -87,6 +87,7 @@
|
|||||||
#include "lyx_gui_misc.h" // WarnReadonly()
|
#include "lyx_gui_misc.h" // WarnReadonly()
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
|
#include "exporter.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
@ -106,7 +107,9 @@ using std::istringstream;
|
|||||||
// all these externs should eventually be removed.
|
// all these externs should eventually be removed.
|
||||||
extern BufferList bufferlist;
|
extern BufferList bufferlist;
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
extern void MenuExport(Buffer *, string const &);
|
extern void MenuExport(Buffer *, string const &);
|
||||||
|
#endif
|
||||||
extern LyXAction lyxaction;
|
extern LyXAction lyxaction;
|
||||||
|
|
||||||
|
|
||||||
@ -3318,6 +3321,8 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
|
|||||||
|
|
||||||
int Buffer::runLaTeX()
|
int Buffer::runLaTeX()
|
||||||
{
|
{
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
|
|
||||||
if (!users->text) return 0;
|
if (!users->text) return 0;
|
||||||
|
|
||||||
ProhibitInput(users);
|
ProhibitInput(users);
|
||||||
@ -3376,6 +3381,7 @@ int Buffer::runLaTeX()
|
|||||||
AllowInput(users);
|
AllowInput(users);
|
||||||
|
|
||||||
return latex.getNumErrors();
|
return latex.getNumErrors();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3839,7 +3845,11 @@ bool Buffer::Dispatch(int action, string const & argument)
|
|||||||
bool dispatched = true;
|
bool dispatched = true;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case LFUN_EXPORT:
|
case LFUN_EXPORT:
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
Exporter::Export(this, argument, false);
|
||||||
|
#else
|
||||||
MenuExport(this, argument);
|
MenuExport(this, argument);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
//#define NEW_EXPORT 1
|
||||||
|
|
||||||
/** These are all the lyxfunctions (as enums).
|
/** These are all the lyxfunctions (as enums).
|
||||||
Please add new functions at the end of the enum, right
|
Please add new functions at the end of the enum, right
|
||||||
before LFUN_LASTACTION.
|
before LFUN_LASTACTION.
|
||||||
@ -27,11 +29,15 @@ enum kb_action {
|
|||||||
LFUN_MENUWRITEAS,
|
LFUN_MENUWRITEAS,
|
||||||
LFUN_MENUPRINT,
|
LFUN_MENUPRINT,
|
||||||
LFUN_MENUSENDTO,
|
LFUN_MENUSENDTO,
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
LFUN_RUNLATEX,
|
LFUN_RUNLATEX,
|
||||||
|
#endif
|
||||||
LFUN_BUILDPROG, // 10
|
LFUN_BUILDPROG, // 10
|
||||||
LFUN_TOCVIEW,
|
LFUN_TOCVIEW,
|
||||||
LFUN_PREVIEW,
|
LFUN_PREVIEW,
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
LFUN_PREVIEWPS,
|
LFUN_PREVIEWPS,
|
||||||
|
#endif
|
||||||
LFUN_CLOSEBUFFER,
|
LFUN_CLOSEBUFFER,
|
||||||
LFUN_BUFFER_PRINT, // ARRae 20000313
|
LFUN_BUFFER_PRINT, // ARRae 20000313
|
||||||
LFUN_PRINTER_PARAMS_GET, // ARRae 20000313
|
LFUN_PRINTER_PARAMS_GET, // ARRae 20000313
|
||||||
@ -191,7 +197,9 @@ enum kb_action {
|
|||||||
LFUN_BACKSPACE_SKIP, // 170
|
LFUN_BACKSPACE_SKIP, // 170
|
||||||
LFUN_DELETE_SKIP,
|
LFUN_DELETE_SKIP,
|
||||||
LFUN_MENUNEWTMPLT, // Asger 1997-02-02
|
LFUN_MENUNEWTMPLT, // Asger 1997-02-02
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
LFUN_RUNDVIPS, // Asger 1997-02-02
|
LFUN_RUNDVIPS, // Asger 1997-02-02
|
||||||
|
#endif
|
||||||
LFUN_MENURELOAD, // Asger 1997-02-02
|
LFUN_MENURELOAD, // Asger 1997-02-02
|
||||||
LFUN_FAX, // Asger 1997-02-10
|
LFUN_FAX, // Asger 1997-02-10
|
||||||
LFUN_RECONFIGURE, // Asger 1997-02-14
|
LFUN_RECONFIGURE, // Asger 1997-02-14
|
||||||
@ -272,6 +280,7 @@ enum kb_action {
|
|||||||
LFUN_TABULAR_FEATURE, // Jug 20000728
|
LFUN_TABULAR_FEATURE, // Jug 20000728
|
||||||
LFUN_LAYOUT_TABULAR, // Jug 20000731
|
LFUN_LAYOUT_TABULAR, // Jug 20000731
|
||||||
LFUN_SCROLL_INSET, // Jug 20000801
|
LFUN_SCROLL_INSET, // Jug 20000801
|
||||||
|
LFUN_UPDATE, // Dekel 20000805
|
||||||
LFUN_INDEX_INSERT, // Angus 20000803
|
LFUN_INDEX_INSERT, // Angus 20000803
|
||||||
LFUN_REF_CREATE, // Angus 20000807
|
LFUN_REF_CREATE, // Angus 20000807
|
||||||
LFUN_SCREEN_FONT_UPDATE, // ARRae 20000813
|
LFUN_SCREEN_FONT_UPDATE, // ARRae 20000813
|
||||||
|
406
src/converter.C
Normal file
406
src/converter.C
Normal file
@ -0,0 +1,406 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 1995 Matthias Ettrich
|
||||||
|
* Copyright 1995-2000 The LyX Team.
|
||||||
|
*
|
||||||
|
* ====================================================== */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
#include <stack>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "converter.h"
|
||||||
|
#include "lyxrc.h"
|
||||||
|
#include "support/syscall.h"
|
||||||
|
#include "support/path.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "buffer.h"
|
||||||
|
|
||||||
|
#include "bufferview_funcs.h"
|
||||||
|
#include "LaTeX.h"
|
||||||
|
#include "LyXView.h"
|
||||||
|
#include "minibuffer.h"
|
||||||
|
#include "lyx_gui_misc.h"
|
||||||
|
|
||||||
|
using std::map;
|
||||||
|
using std::vector;
|
||||||
|
using std::queue;
|
||||||
|
using std::stack;
|
||||||
|
|
||||||
|
extern void ShowMessage(Buffer * buf,
|
||||||
|
string const & msg1,
|
||||||
|
string const & msg2 = string(),
|
||||||
|
string const & msg3 = string(), int delay = 6);
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
map<string, Format> Formats::formats;
|
||||||
|
vector<Command> Converter::commands;
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Format::Format(string const & n) : name(n), in_degree(0)
|
||||||
|
{
|
||||||
|
struct Item {
|
||||||
|
char const * name;
|
||||||
|
char const * prettyname;
|
||||||
|
};
|
||||||
|
Item items[] = {
|
||||||
|
{ "tex", "LaTeX" },
|
||||||
|
{ "dvi", "DVI" },
|
||||||
|
{ "ps", "PostScript" },
|
||||||
|
{ "txt", "Ascii" },
|
||||||
|
{ "html", "HTML" },
|
||||||
|
{ "pdf", "PDF" },
|
||||||
|
{ 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
prettyname = n;
|
||||||
|
for (int i = 0; items[i].name != 0; ++i)
|
||||||
|
if (items[i].name == n) {
|
||||||
|
prettyname = items[i].prettyname;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Formats::Add(string const & name)
|
||||||
|
{
|
||||||
|
if (formats.find(name) == formats.end())
|
||||||
|
formats[name] = Format(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Formats::SetViewer(string const & name, string const & command)
|
||||||
|
{
|
||||||
|
Add(name);
|
||||||
|
Format * f = GetFormat(name);
|
||||||
|
if (!f->viewer.empty())
|
||||||
|
lyxerr << "Error: a viewer for " << name
|
||||||
|
<< " is already defined!" << endl;
|
||||||
|
else
|
||||||
|
f->viewer = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Formats::View(string const & filename)
|
||||||
|
{
|
||||||
|
string extension = GetExtension(filename);
|
||||||
|
Format * format = GetFormat(extension);
|
||||||
|
if (!format || format->viewer.empty()) {
|
||||||
|
WriteAlert(_("Can not view file"),
|
||||||
|
_("No information for viewing ")
|
||||||
|
+ Formats::PrettyName(extension));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string command = format->viewer;
|
||||||
|
command = subst(command, "$$FName", filename);
|
||||||
|
#ifndef __EMX__
|
||||||
|
command += " &";
|
||||||
|
#else
|
||||||
|
// OS/2 cmd.exe has another use for '&'
|
||||||
|
// This is not NLS safe, but it's OK, I think.
|
||||||
|
string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
|
||||||
|
if (sh.empty()) {
|
||||||
|
// COMSPEC is set, unless user unsets
|
||||||
|
sh = OnlyFilename(GetEnvPath("COMSPEC"));
|
||||||
|
if (sh.empty())
|
||||||
|
sh = "cmd.exe";
|
||||||
|
}
|
||||||
|
sh = lowercase(sh);
|
||||||
|
if (contains(sh, "cmd.exe")
|
||||||
|
|| contains(sh, "4os2.exe"))
|
||||||
|
command = "start /min/n " + command;
|
||||||
|
else
|
||||||
|
command += " &";
|
||||||
|
#endif
|
||||||
|
lyxerr << "Executing command: " << command << endl;
|
||||||
|
//ShowMessage(buffer, _("Executing command:"), command);
|
||||||
|
Systemcalls one;
|
||||||
|
int res = one.startscript(Systemcalls::System, command);
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
WriteAlert(_("Can not view file"),
|
||||||
|
_("Error while executing"),
|
||||||
|
command.substr(0, 50));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Format * Formats::GetFormat(string const & name)
|
||||||
|
{
|
||||||
|
map<string, Format>::iterator it = formats.find(name);
|
||||||
|
if (it != formats.end())
|
||||||
|
return &(*it).second;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Formats::PrettyName(string const & name)
|
||||||
|
{
|
||||||
|
|
||||||
|
string format;
|
||||||
|
Converter::SplitFormat(name, format);
|
||||||
|
Format * f = GetFormat(format);
|
||||||
|
if (f)
|
||||||
|
return f->prettyname;
|
||||||
|
else
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Converter::Add(string const & from, string const & to,
|
||||||
|
string const & command, string const & flags)
|
||||||
|
{
|
||||||
|
for (vector<Command>::const_iterator cit = commands.begin();
|
||||||
|
cit != commands.end(); ++cit)
|
||||||
|
if ((*cit).from == from && (*cit).to == to) {
|
||||||
|
lyxerr << "Error: Convertor from " << from
|
||||||
|
<< " to " << to
|
||||||
|
<< " already exists!" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool original_dir = flags == "origdir";
|
||||||
|
commands.push_back(Command(from, to, command, original_dir));
|
||||||
|
|
||||||
|
Formats::Add(from);
|
||||||
|
Formats::Add(to);
|
||||||
|
++Formats::GetFormat(to)->in_degree;
|
||||||
|
}
|
||||||
|
|
||||||
|
vector< pair<string,string> >
|
||||||
|
Converter::GetReachable(string const & from, bool only_viewable)
|
||||||
|
{
|
||||||
|
vector< pair<string,string> > result;
|
||||||
|
Format * format = Formats::GetFormat(from);
|
||||||
|
if (!format)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
int sort_start = 0;
|
||||||
|
if (!only_viewable || !format->viewer.empty()) {
|
||||||
|
result.push_back(pair<string,string>(from, format->prettyname));
|
||||||
|
sort_start = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
queue< vector<Command>::iterator > Q;
|
||||||
|
for (vector<Command>::iterator it = commands.begin();
|
||||||
|
it != commands.end(); ++it)
|
||||||
|
if ((*it).from == from) {
|
||||||
|
Q.push(it);
|
||||||
|
(*it).visited = true;
|
||||||
|
} else
|
||||||
|
(*it).visited = false;
|
||||||
|
|
||||||
|
while (!Q.empty()) {
|
||||||
|
vector<Command>::iterator it = Q.front();
|
||||||
|
format = Formats::GetFormat((*it).to);
|
||||||
|
string name = format->name;
|
||||||
|
string prettyname = format->prettyname;
|
||||||
|
if (format->in_degree > 1) {
|
||||||
|
name += ":" + (*it).from;
|
||||||
|
string tmp;
|
||||||
|
split((*it).command, tmp, ' ');
|
||||||
|
prettyname += _("(using ") + tmp + ")";
|
||||||
|
}
|
||||||
|
if (!only_viewable || !format->viewer.empty())
|
||||||
|
result.push_back(pair<string,string>(name, prettyname));
|
||||||
|
Q.pop();
|
||||||
|
for (vector<Command>::iterator it2 = commands.begin();
|
||||||
|
it2 != commands.end(); ++it2)
|
||||||
|
if (!(*it2).visited && (*it).to == (*it2).from) {
|
||||||
|
Q.push(it2);
|
||||||
|
(*it2).visited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(result.begin() + sort_start, result.end());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Converter::convert(Buffer * buffer, string const & from_file,
|
||||||
|
string const & to_format)
|
||||||
|
|
||||||
|
{
|
||||||
|
string using_format, format;
|
||||||
|
using_format = SplitFormat(to_format, format);
|
||||||
|
string from_format = GetExtension(from_file);
|
||||||
|
if (from_format == format)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
queue< vector<Command>::iterator > Q;
|
||||||
|
for (vector<Command>::iterator it = commands.begin();
|
||||||
|
it != commands.end(); ++it)
|
||||||
|
if ((*it).from == from_format) {
|
||||||
|
Q.push(it);
|
||||||
|
(*it).visited = true;
|
||||||
|
(*it).previous = commands.end();
|
||||||
|
} else
|
||||||
|
(*it).visited = false;
|
||||||
|
|
||||||
|
if (Q.empty()) {
|
||||||
|
WriteAlert(_("Can not convert file"),
|
||||||
|
("Unknown format ") + from_format);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
vector<Command>::iterator it;
|
||||||
|
while (!Q.empty()) {
|
||||||
|
it = Q.front();
|
||||||
|
if ((*it).to == format &&
|
||||||
|
(using_format.empty() || using_format == (*it).from)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Q.pop();
|
||||||
|
for (vector<Command>::iterator it2 = commands.begin();
|
||||||
|
it2 != commands.end(); ++it2)
|
||||||
|
if (!(*it2).visited && (*it).to == (*it2).from) {
|
||||||
|
Q.push(it2);
|
||||||
|
(*it2).visited = true;
|
||||||
|
(*it2).previous = it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
WriteAlert(_("Can not convert file"),
|
||||||
|
_("No information for converting from ")
|
||||||
|
+ Formats::PrettyName(from_format) + _(" to ")
|
||||||
|
+ Formats::PrettyName(to_format));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack< vector<Command>::iterator > S;
|
||||||
|
while (it != commands.end()) {
|
||||||
|
S.push(it);
|
||||||
|
it = (*it).previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Path p(OnlyPath(buffer->fileName()));
|
||||||
|
Path p(OnlyPath(from_file));
|
||||||
|
|
||||||
|
string basename = ChangeExtension(from_file, "");
|
||||||
|
while (!S.empty()) {
|
||||||
|
it = S.top();
|
||||||
|
S.pop();
|
||||||
|
lyxerr << "Converting from "
|
||||||
|
<< (*it).from << " to " << (*it).to << endl;
|
||||||
|
|
||||||
|
if ((*it).from == "tex" &&
|
||||||
|
( (*it).to == "dvi" || (*it).to == "pdf") ) {
|
||||||
|
lyxrc.pdf_mode = (*it).to == "pdf";
|
||||||
|
if (!runLaTeX(buffer, (*it).command))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
string infile = ChangeExtension(from_file, (*it).from);
|
||||||
|
if (!(*it).original_dir)
|
||||||
|
infile = OnlyFilename(infile);
|
||||||
|
string outfile = ChangeExtension(infile, (*it).to);
|
||||||
|
|
||||||
|
string command = (*it).command;
|
||||||
|
command = subst(command, "$$FName", infile);
|
||||||
|
command = subst(command, "$$BaseName", basename);
|
||||||
|
command = subst(command, "$$OutName", outfile);
|
||||||
|
lyxerr << "Calling " << command << endl;
|
||||||
|
ShowMessage(buffer, _("Executing command:"), command);
|
||||||
|
|
||||||
|
Systemcalls one;
|
||||||
|
int res;
|
||||||
|
if ((*it).original_dir) {
|
||||||
|
Path p(buffer->filepath);
|
||||||
|
res = one.startscript(Systemcalls::System, command);
|
||||||
|
} else
|
||||||
|
res = one.startscript(Systemcalls::System, command);
|
||||||
|
if (res) {
|
||||||
|
WriteAlert(_("Can not convert file"),
|
||||||
|
"Error while executing",
|
||||||
|
command.substr(0, 50));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string Converter::SplitFormat(string const & str, string & format)
|
||||||
|
{
|
||||||
|
string using_format = split(str, format, ':');
|
||||||
|
if (format.empty())
|
||||||
|
format = "dvi";
|
||||||
|
return using_format;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Converter::runLaTeX(Buffer * buffer, string const & command)
|
||||||
|
{
|
||||||
|
|
||||||
|
BufferView * bv = buffer->getUser();
|
||||||
|
|
||||||
|
if (!bv->text) return 0;
|
||||||
|
|
||||||
|
ProhibitInput(bv);
|
||||||
|
|
||||||
|
string name = buffer->getLatexName();
|
||||||
|
|
||||||
|
bv->owner()->getMiniBuffer()->Set(_("Running LaTeX..."));
|
||||||
|
|
||||||
|
// Remove all error insets
|
||||||
|
bool a = bv->removeAutoInsets();
|
||||||
|
|
||||||
|
// do the LaTex run(s)
|
||||||
|
TeXErrors terr;
|
||||||
|
LaTeX latex(command, name, buffer->filepath);
|
||||||
|
int result = latex.run(terr,
|
||||||
|
bv->owner()->getMiniBuffer()); // running latex
|
||||||
|
|
||||||
|
if ((result & LaTeX::ERRORS)) {
|
||||||
|
// Insert all errors as errors boxes
|
||||||
|
bv->insertErrors(terr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we removed error insets before we ran LaTeX or if we inserted
|
||||||
|
// error insets after we ran LaTeX this must be run:
|
||||||
|
if (a || (result & LaTeX::ERRORS)){
|
||||||
|
bv->redraw();
|
||||||
|
bv->fitCursor();
|
||||||
|
//bv->updateScrollbar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check return value from latex.run().
|
||||||
|
if ((result & LaTeX::NO_LOGFILE)) {
|
||||||
|
WriteAlert(_("LaTeX did not work!"),
|
||||||
|
_("Missing log file:"), name);
|
||||||
|
} else if ((result & LaTeX::ERRORS)) {
|
||||||
|
int num_errors = latex.getNumErrors();
|
||||||
|
string s;
|
||||||
|
string t;
|
||||||
|
if (num_errors == 1) {
|
||||||
|
s = _("One error detected");
|
||||||
|
t = _("You should try to fix it.");
|
||||||
|
} else {
|
||||||
|
s = tostr(num_errors);
|
||||||
|
s += _(" errors detected.");
|
||||||
|
t = _("You should try to fix them.");
|
||||||
|
}
|
||||||
|
WriteAlert(_("There were errors during the LaTeX run."),
|
||||||
|
s, t);
|
||||||
|
}
|
||||||
|
AllowInput(bv);
|
||||||
|
|
||||||
|
return (result & (LaTeX::NO_LOGFILE | LaTeX::ERRORS)) == 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
107
src/converter.h
Normal file
107
src/converter.h
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 1995 Matthias Ettrich
|
||||||
|
* Copyright 1995-2000 The LyX Team.
|
||||||
|
*
|
||||||
|
* ====================================================== */
|
||||||
|
|
||||||
|
#ifndef CONVERTER_H
|
||||||
|
#define CONVERTER_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include "LString.h"
|
||||||
|
|
||||||
|
class Buffer;
|
||||||
|
|
||||||
|
struct Command {
|
||||||
|
Command(string const & f, string const & t, string const & c,
|
||||||
|
bool o)
|
||||||
|
: from(f), to(t), command(c), original_dir(o) {}
|
||||||
|
///
|
||||||
|
string from;
|
||||||
|
///
|
||||||
|
string to;
|
||||||
|
///
|
||||||
|
string command;
|
||||||
|
///
|
||||||
|
bool original_dir;
|
||||||
|
///
|
||||||
|
bool visited;
|
||||||
|
///
|
||||||
|
std::vector<Command>::iterator previous;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Format {
|
||||||
|
public:
|
||||||
|
Format() : in_degree(0) {}
|
||||||
|
///
|
||||||
|
Format(string const & n);
|
||||||
|
///
|
||||||
|
string name;
|
||||||
|
///
|
||||||
|
string prettyname;
|
||||||
|
///
|
||||||
|
string viewer;
|
||||||
|
///
|
||||||
|
int in_degree;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Formats {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
static
|
||||||
|
void Add(string const & name);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
void SetViewer(string const & name, string const & command);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
bool View(string const & filename);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
Format * GetFormat(string const & name);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
string PrettyName(string const & name);
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
static
|
||||||
|
std::map<string, Format> formats;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Converter {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
static
|
||||||
|
void Add(string const & from, string const & to,
|
||||||
|
string const & command, string const & flags);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
std::vector<std::pair<string, string> > GetReachable(string const & from,
|
||||||
|
bool only_viewable = false);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
bool convert(Buffer * buffer, string const & from_file,
|
||||||
|
string const & to_format);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
string SplitFormat(string const & str, string & format);
|
||||||
|
private:
|
||||||
|
///
|
||||||
|
static
|
||||||
|
bool runLaTeX(Buffer * buffer, string const & command);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
std::vector<Command> commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
111
src/exporter.C
Normal file
111
src/exporter.C
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 1995 Matthias Ettrich
|
||||||
|
* Copyright 1995-2000 The LyX Team.
|
||||||
|
*
|
||||||
|
* ====================================================== */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "exporter.h"
|
||||||
|
#include "converter.h"
|
||||||
|
|
||||||
|
#include "buffer.h"
|
||||||
|
#include "support/path.h"
|
||||||
|
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
using std::pair;
|
||||||
|
|
||||||
|
extern void ShowMessage(Buffer * buf,
|
||||||
|
string const & msg1,
|
||||||
|
string const & msg2 = string(),
|
||||||
|
string const & msg3 = string(), int delay = 6);
|
||||||
|
|
||||||
|
bool Exporter::Export(Buffer * buffer, string const & format0,
|
||||||
|
bool put_in_tempdir)
|
||||||
|
{
|
||||||
|
string using_format, format;
|
||||||
|
using_format = Converter::SplitFormat(format0, format);
|
||||||
|
|
||||||
|
string filename = buffer->fileName();
|
||||||
|
string backend_format = BufferExtension(buffer);
|
||||||
|
bool only_backend = backend_format == format;
|
||||||
|
|
||||||
|
//string file = buffer->getLatexName(true);
|
||||||
|
string file = filename;
|
||||||
|
if (!buffer->tmppath.empty())
|
||||||
|
file = AddName(buffer->tmppath, file);
|
||||||
|
file = ChangeExtension(file, backend_format);
|
||||||
|
|
||||||
|
if (buffer->isLinuxDoc())
|
||||||
|
buffer->makeLinuxDocFile(file, only_backend);
|
||||||
|
else if (only_backend)
|
||||||
|
buffer->makeLaTeXFile(file, string(), true);
|
||||||
|
else
|
||||||
|
buffer->makeLaTeXFile(file, buffer->filepath, false);
|
||||||
|
|
||||||
|
bool return_value = Converter::convert(buffer, file, format0);
|
||||||
|
if (!return_value)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!put_in_tempdir) {
|
||||||
|
file = ChangeExtension(file, format);
|
||||||
|
string outfile = ChangeExtension(filename, format);
|
||||||
|
if (file != outfile)
|
||||||
|
rename(file.c_str(), outfile.c_str());
|
||||||
|
|
||||||
|
ShowMessage(buffer,
|
||||||
|
_("Document exported as ")
|
||||||
|
+ Formats::PrettyName(format)
|
||||||
|
+ _(" to file `")
|
||||||
|
+ MakeDisplayPath(outfile) +'\'');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Exporter::Preview(Buffer * buffer, string const & format0)
|
||||||
|
{
|
||||||
|
if (!Export(buffer, format0, true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string format;
|
||||||
|
Converter::SplitFormat(format0, format);
|
||||||
|
|
||||||
|
string filename = buffer->fileName();
|
||||||
|
if (!buffer->tmppath.empty())
|
||||||
|
filename = AddName(buffer->tmppath, filename);
|
||||||
|
filename = ChangeExtension(filename, format);
|
||||||
|
return Formats::View(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<pair<string, string> > Exporter::GetExportableFormats(Buffer * buffer)
|
||||||
|
{
|
||||||
|
return Converter::GetReachable(BufferExtension(buffer), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vector<pair<string, string> > Exporter::GetViewableFormats(Buffer * buffer)
|
||||||
|
{
|
||||||
|
return Converter::GetReachable(BufferExtension(buffer), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
string Exporter::BufferExtension(Buffer * buffer)
|
||||||
|
{
|
||||||
|
if (buffer->isLinuxDoc())
|
||||||
|
return "sgml";
|
||||||
|
else
|
||||||
|
return "tex";
|
||||||
|
}
|
46
src/exporter.h
Normal file
46
src/exporter.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/* This file is part of
|
||||||
|
* ======================================================
|
||||||
|
*
|
||||||
|
* LyX, The Document Processor
|
||||||
|
*
|
||||||
|
* Copyright 1995 Matthias Ettrich
|
||||||
|
* Copyright 1995-2000 The LyX Team.
|
||||||
|
*
|
||||||
|
* ====================================================== */
|
||||||
|
|
||||||
|
#ifndef EXPORTER_H
|
||||||
|
#define EXPORTER_H
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "LString.h"
|
||||||
|
|
||||||
|
class Buffer;
|
||||||
|
|
||||||
|
class Exporter {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
static
|
||||||
|
bool Export(Buffer * buffer, string const & format,
|
||||||
|
bool put_in_tempdir);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
bool Preview(Buffer * buffer, string const & format);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
std::vector<std::pair<string, string> > GetExportableFormats(Buffer * buffer);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
std::vector<std::pair<string, string> > GetViewableFormats(Buffer * buffer);
|
||||||
|
///
|
||||||
|
static
|
||||||
|
string BufferExtension(Buffer * buffer);
|
||||||
|
};
|
||||||
|
|
||||||
|
//#define NEW_EXPORT 1
|
||||||
|
|
||||||
|
#endif
|
@ -24,6 +24,7 @@
|
|||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
|
#include "exporter.h"
|
||||||
#include "minibuffer.h"
|
#include "minibuffer.h"
|
||||||
|
|
||||||
extern LyXRC lyxrc;
|
extern LyXRC lyxrc;
|
||||||
@ -171,6 +172,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
|||||||
}
|
}
|
||||||
Path p(path);
|
Path p(path);
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
// there are three cases here:
|
// there are three cases here:
|
||||||
// 1. we print to a file
|
// 1. we print to a file
|
||||||
// 2. we print direct to a printer
|
// 2. we print direct to a printer
|
||||||
@ -207,6 +209,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
|||||||
result = RunScript(buffer, false, command);
|
result = RunScript(buffer, false, command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "LyXView.h"
|
#include "LyXView.h"
|
||||||
#include "MenuBackend.h"
|
#include "MenuBackend.h"
|
||||||
#include "Menubar_pimpl.h"
|
#include "Menubar_pimpl.h"
|
||||||
|
#include "exporter.h"
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
@ -268,6 +269,30 @@ void Menubar::Pimpl::add_documents(int menu, string const & extra_label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Menubar::Pimpl::add_formats(int menu, string const & extra_label,
|
||||||
|
std::vector<int> & /*smn*/,
|
||||||
|
StrPool & strpool,
|
||||||
|
kb_action action, bool viewable)
|
||||||
|
{
|
||||||
|
std::vector<pair<string,string> > names =
|
||||||
|
viewable
|
||||||
|
? Exporter::GetViewableFormats(owner_->buffer())
|
||||||
|
: Exporter::GetExportableFormats(owner_->buffer());
|
||||||
|
|
||||||
|
for (std::vector<pair<string,string> >::const_iterator cit = names.begin();
|
||||||
|
cit != names.end() ; ++cit) {
|
||||||
|
int action2 =
|
||||||
|
lyxaction.getPseudoAction(action, (*cit).first);
|
||||||
|
string label = (*cit).second
|
||||||
|
+ "%x" + tostr(action2);
|
||||||
|
if ((cit + 1) == names.end())
|
||||||
|
label += extra_label;
|
||||||
|
|
||||||
|
fl_addtopup(menu, strpool.add(label));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
|
int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
|
||||||
string const & menu_name,
|
string const & menu_name,
|
||||||
std::vector<int> & smn, StrPool & strpool)
|
std::vector<int> & smn, StrPool & strpool)
|
||||||
@ -403,11 +428,25 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
|
|||||||
add_documents(menu, extra_label, smn, strpool);
|
add_documents(menu, extra_label, smn, strpool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case MenuItem::Lastfiles:
|
case MenuItem::Lastfiles:
|
||||||
add_lastfiles(menu, extra_label, smn, strpool);
|
add_lastfiles(menu, extra_label, smn, strpool);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case MenuItem::ViewFormats:
|
||||||
|
add_formats(menu, extra_label, smn, strpool,
|
||||||
|
LFUN_PREVIEW, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MenuItem::UpdateFormats:
|
||||||
|
add_formats(menu, extra_label, smn, strpool,
|
||||||
|
LFUN_UPDATE, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MenuItem::ExportFormats:
|
||||||
|
add_formats(menu, extra_label, smn, strpool,
|
||||||
|
LFUN_EXPORT, false);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return menu;
|
return menu;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "LString.h"
|
#include "LString.h"
|
||||||
#include "frontends/Menubar.h"
|
#include "frontends/Menubar.h"
|
||||||
|
#include "commandtags.h"
|
||||||
#include FORMS_H_LOCATION
|
#include FORMS_H_LOCATION
|
||||||
class LyXView;
|
class LyXView;
|
||||||
class MenuBackend;
|
class MenuBackend;
|
||||||
@ -56,6 +57,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void add_documents(int menu, string const & extra_label,
|
void add_documents(int menu, string const & extra_label,
|
||||||
std::vector<int> & smn, StrPool & strpool);
|
std::vector<int> & smn, StrPool & strpool);
|
||||||
|
/// Add to "menu" the list of exportable/viewable formats
|
||||||
|
/// (add "extra_label" to the last entry)
|
||||||
|
void add_formats(int menu, string const & extra_label,
|
||||||
|
std::vector<int> & smn, StrPool & strpool,
|
||||||
|
kb_action action, bool viewable);
|
||||||
///
|
///
|
||||||
int create_submenu(Window win, LyXView * view,
|
int create_submenu(Window win, LyXView * view,
|
||||||
string const & menuname,
|
string const & menuname,
|
||||||
|
25
src/lyx_cb.C
25
src/lyx_cb.C
@ -43,6 +43,7 @@
|
|||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
#include "CutAndPaste.h"
|
#include "CutAndPaste.h"
|
||||||
|
#include "exporter.h"
|
||||||
|
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
using std::copy;
|
using std::copy;
|
||||||
@ -297,7 +298,7 @@ bool MenuWriteAs(Buffer * buffer)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
int MenuRunLaTeX(Buffer * buffer)
|
int MenuRunLaTeX(Buffer * buffer)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -326,7 +327,7 @@ int MenuRunLaTeX(Buffer * buffer)
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int MenuBuildProg(Buffer * buffer)
|
int MenuBuildProg(Buffer * buffer)
|
||||||
{
|
{
|
||||||
@ -388,7 +389,7 @@ int MenuRunChktex(Buffer * buffer)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
int MakeLaTeXOutput(Buffer * buffer)
|
int MakeLaTeXOutput(Buffer * buffer)
|
||||||
{
|
{
|
||||||
// Who cares?
|
// Who cares?
|
||||||
@ -601,7 +602,7 @@ bool PreviewPostscript(Buffer * buffer)
|
|||||||
AllowInput(current_view);
|
AllowInput(current_view);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void MenuFax(Buffer * buffer)
|
void MenuFax(Buffer * buffer)
|
||||||
{
|
{
|
||||||
@ -609,6 +610,15 @@ void MenuFax(Buffer * buffer)
|
|||||||
//if (!bv->text)
|
//if (!bv->text)
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
// Generate postscript file
|
||||||
|
if (!Exporter::Export(buffer, "ps", true))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Send fax
|
||||||
|
string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
|
||||||
|
".ps"));
|
||||||
|
#else
|
||||||
// Generate postscript file
|
// Generate postscript file
|
||||||
if (!CreatePostscript(buffer, true)) {
|
if (!CreatePostscript(buffer, true)) {
|
||||||
return;
|
return;
|
||||||
@ -617,6 +627,7 @@ void MenuFax(Buffer * buffer)
|
|||||||
// Send fax
|
// Send fax
|
||||||
string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
|
string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
|
||||||
".ps_tmp"));
|
".ps_tmp"));
|
||||||
|
#endif
|
||||||
string path = OnlyPath (buffer->fileName());
|
string path = OnlyPath (buffer->fileName());
|
||||||
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
||||||
path = buffer->tmppath;
|
path = buffer->tmppath;
|
||||||
@ -631,6 +642,7 @@ void MenuFax(Buffer * buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
// Returns false if we fail
|
// Returns false if we fail
|
||||||
bool PreviewDVI(Buffer * buffer)
|
bool PreviewDVI(Buffer * buffer)
|
||||||
{
|
{
|
||||||
@ -952,6 +964,7 @@ void MenuExport(Buffer * buffer, string const & extyp)
|
|||||||
ShowMessage(buffer, _("Unknown export type: ") + extyp);
|
ShowMessage(buffer, _("Unknown export type: ") + extyp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void QuitLyX()
|
void QuitLyX()
|
||||||
@ -1169,7 +1182,7 @@ void LayoutsCB(int sel, void *)
|
|||||||
tmp.c_str());
|
tmp.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
/*
|
/*
|
||||||
* SGML Linuxdoc support:
|
* SGML Linuxdoc support:
|
||||||
* (flag == 0) make TeX output
|
* (flag == 0) make TeX output
|
||||||
@ -1287,7 +1300,7 @@ int RunDocBook(int flag, string const & filename)
|
|||||||
current_view->buffer()->redraw();
|
current_view->buffer()->redraw();
|
||||||
return errorcode;
|
return errorcode;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void MenuLayoutCharacter()
|
void MenuLayoutCharacter()
|
||||||
{
|
{
|
||||||
|
@ -92,6 +92,7 @@ using std::istringstream;
|
|||||||
#include "menus.h"
|
#include "menus.h"
|
||||||
#endif
|
#endif
|
||||||
#include "FloatList.h"
|
#include "FloatList.h"
|
||||||
|
#include "exporter.h"
|
||||||
#include "FontLoader.h"
|
#include "FontLoader.h"
|
||||||
#include "TextCache.h"
|
#include "TextCache.h"
|
||||||
|
|
||||||
@ -112,15 +113,21 @@ extern kb_keymap * toplevel_keymap;
|
|||||||
|
|
||||||
extern bool MenuWrite(Buffer *);
|
extern bool MenuWrite(Buffer *);
|
||||||
extern bool MenuWriteAs(Buffer *);
|
extern bool MenuWriteAs(Buffer *);
|
||||||
|
#ifdef NEW_MENUBAR
|
||||||
extern int MenuRunLaTeX(Buffer *);
|
extern int MenuRunLaTeX(Buffer *);
|
||||||
|
#endif
|
||||||
extern int MenuBuildProg(Buffer *);
|
extern int MenuBuildProg(Buffer *);
|
||||||
extern int MenuRunChktex(Buffer *);
|
extern int MenuRunChktex(Buffer *);
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
extern bool CreatePostscript(Buffer *, bool);
|
extern bool CreatePostscript(Buffer *, bool);
|
||||||
|
#endif
|
||||||
extern void MenuPrint(Buffer *);
|
extern void MenuPrint(Buffer *);
|
||||||
extern void MenuSendto();
|
extern void MenuSendto();
|
||||||
extern void QuitLyX();
|
extern void QuitLyX();
|
||||||
extern void MenuFax(Buffer *);
|
extern void MenuFax(Buffer *);
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
extern void MenuExport(Buffer *, string const &);
|
extern void MenuExport(Buffer *, string const &);
|
||||||
|
#endif
|
||||||
extern void show_symbols_form(LyXFunc *);
|
extern void show_symbols_form(LyXFunc *);
|
||||||
|
|
||||||
extern LyXAction lyxaction;
|
extern LyXAction lyxaction;
|
||||||
@ -128,8 +135,10 @@ extern LyXAction lyxaction;
|
|||||||
extern tex_accent_struct get_accent(kb_action action);
|
extern tex_accent_struct get_accent(kb_action action);
|
||||||
|
|
||||||
extern void AutoSave(BufferView *);
|
extern void AutoSave(BufferView *);
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
extern bool PreviewDVI(Buffer *);
|
extern bool PreviewDVI(Buffer *);
|
||||||
extern bool PreviewPostscript(Buffer *);
|
extern bool PreviewPostscript(Buffer *);
|
||||||
|
#endif
|
||||||
extern void MenuInsertLabel(char const *);
|
extern void MenuInsertLabel(char const *);
|
||||||
extern void MenuLayoutCharacter();
|
extern void MenuLayoutCharacter();
|
||||||
extern void MenuLayoutParagraph();
|
extern void MenuLayoutParagraph();
|
||||||
@ -486,6 +495,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
|||||||
static bool noLaTeX = lyxrc.latex_command == "none";
|
static bool noLaTeX = lyxrc.latex_command == "none";
|
||||||
bool disable = false;
|
bool disable = false;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
case LFUN_PREVIEW:
|
case LFUN_PREVIEW:
|
||||||
disable = noLaTeX || lyxrc.view_dvi_command == "none";
|
disable = noLaTeX || lyxrc.view_dvi_command == "none";
|
||||||
break;
|
break;
|
||||||
@ -496,6 +506,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
|||||||
case LFUN_RUNDVIPS:
|
case LFUN_RUNDVIPS:
|
||||||
disable = noLaTeX;
|
disable = noLaTeX;
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case LFUN_MENUPRINT:
|
case LFUN_MENUPRINT:
|
||||||
disable = noLaTeX || lyxrc.print_command == "none";
|
disable = noLaTeX || lyxrc.print_command == "none";
|
||||||
break;
|
break;
|
||||||
@ -508,6 +519,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
|||||||
else if (argument == "linuxdoc")
|
else if (argument == "linuxdoc")
|
||||||
disable = lyxrc.linuxdoc_to_lyx_command == "none";
|
disable = lyxrc.linuxdoc_to_lyx_command == "none";
|
||||||
break;
|
break;
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
case LFUN_EXPORT:
|
case LFUN_EXPORT:
|
||||||
if (argument == "latex")
|
if (argument == "latex")
|
||||||
disable = (! buf->isLatex() && ! buf->isLiterate()) ;
|
disable = (! buf->isLatex() && ! buf->isLiterate()) ;
|
||||||
@ -527,6 +539,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
|||||||
else if (argument == "custom")
|
else if (argument == "custom")
|
||||||
disable = (! buf->isLatex() && ! buf->isLiterate());
|
disable = (! buf->isLatex() && ! buf->isLiterate());
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case LFUN_UNDO:
|
case LFUN_UNDO:
|
||||||
disable = buf->undostack.empty();
|
disable = buf->undostack.empty();
|
||||||
break;
|
break;
|
||||||
@ -963,6 +976,15 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
reloadBuffer();
|
reloadBuffer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
case LFUN_UPDATE:
|
||||||
|
Exporter::Export(owner->buffer(), argument, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LFUN_PREVIEW:
|
||||||
|
Exporter::Preview(owner->buffer(), argument);
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case LFUN_PREVIEW:
|
case LFUN_PREVIEW:
|
||||||
PreviewDVI(owner->buffer());
|
PreviewDVI(owner->buffer());
|
||||||
break;
|
break;
|
||||||
@ -974,6 +996,11 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
case LFUN_RUNLATEX:
|
case LFUN_RUNLATEX:
|
||||||
MenuRunLaTeX(owner->buffer());
|
MenuRunLaTeX(owner->buffer());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_RUNDVIPS:
|
||||||
|
CreatePostscript(owner->buffer(), false);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case LFUN_BUILDPROG:
|
case LFUN_BUILDPROG:
|
||||||
MenuBuildProg(owner->buffer());
|
MenuBuildProg(owner->buffer());
|
||||||
@ -982,11 +1009,7 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
case LFUN_RUNCHKTEX:
|
case LFUN_RUNCHKTEX:
|
||||||
MenuRunChktex(owner->buffer());
|
MenuRunChktex(owner->buffer());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_RUNDVIPS:
|
|
||||||
CreatePostscript(owner->buffer(), false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_MENUPRINT:
|
case LFUN_MENUPRINT:
|
||||||
owner->getDialogs()->showPrint();
|
owner->getDialogs()->showPrint();
|
||||||
break;
|
break;
|
||||||
@ -996,7 +1019,11 @@ string LyXFunc::Dispatch(int ac,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_EXPORT:
|
case LFUN_EXPORT:
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
Exporter::Export(owner->buffer(), argument, false);
|
||||||
|
#else
|
||||||
MenuExport(owner->buffer(), argument);
|
MenuExport(owner->buffer(), argument);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_IMPORT:
|
case LFUN_IMPORT:
|
||||||
|
33
src/lyxrc.C
33
src/lyxrc.C
@ -30,6 +30,7 @@
|
|||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
|
#include "converter.h"
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
using std::ofstream;
|
using std::ofstream;
|
||||||
@ -155,6 +156,8 @@ enum LyXRCTags {
|
|||||||
RC_DOCBOOK_TO_HTML_COMMAND,
|
RC_DOCBOOK_TO_HTML_COMMAND,
|
||||||
RC_DOCBOOK_TO_PDF_COMMAND,
|
RC_DOCBOOK_TO_PDF_COMMAND,
|
||||||
RC_WHEEL_JUMP,
|
RC_WHEEL_JUMP,
|
||||||
|
RC_CONVERTER,
|
||||||
|
RC_VIEWER,
|
||||||
RC_NEW_ASK_FILENAME,
|
RC_NEW_ASK_FILENAME,
|
||||||
RC_LAST
|
RC_LAST
|
||||||
};
|
};
|
||||||
@ -176,6 +179,7 @@ keyword_item lyxrcTags[] = {
|
|||||||
{ "\\build_error_filter", RC_BUILD_ERROR_FILTER },
|
{ "\\build_error_filter", RC_BUILD_ERROR_FILTER },
|
||||||
{ "\\check_lastfiles", RC_CHECKLASTFILES },
|
{ "\\check_lastfiles", RC_CHECKLASTFILES },
|
||||||
{ "\\chktex_command", RC_CHKTEX_COMMAND },
|
{ "\\chktex_command", RC_CHKTEX_COMMAND },
|
||||||
|
{ "\\converter", RC_CONVERTER },
|
||||||
{ "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
|
{ "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
|
||||||
{ "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
|
{ "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
|
||||||
{ "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
|
{ "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
|
||||||
@ -270,6 +274,7 @@ keyword_item lyxrcTags[] = {
|
|||||||
{ "\\view_pdf_command", RC_VIEWPDF_COMMAND },
|
{ "\\view_pdf_command", RC_VIEWPDF_COMMAND },
|
||||||
{ "\\view_ps_command", RC_VIEWPS_COMMAND },
|
{ "\\view_ps_command", RC_VIEWPS_COMMAND },
|
||||||
{ "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
|
{ "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
|
||||||
|
{ "\\viewer" ,RC_VIEWER},
|
||||||
{ "\\wheel_jump", RC_WHEEL_JUMP }
|
{ "\\wheel_jump", RC_WHEEL_JUMP }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1106,6 +1111,34 @@ int LyXRC::read(string const & filename)
|
|||||||
if ( lexrc.next())
|
if ( lexrc.next())
|
||||||
new_ask_filename = lexrc.GetBool();
|
new_ask_filename = lexrc.GetBool();
|
||||||
break;
|
break;
|
||||||
|
case RC_CONVERTER:
|
||||||
|
{
|
||||||
|
string from, to, command, flags;
|
||||||
|
if (lexrc.next())
|
||||||
|
from = lexrc.GetString();
|
||||||
|
if (lexrc.next())
|
||||||
|
to = lexrc.GetString();
|
||||||
|
if (lexrc.next())
|
||||||
|
command = lexrc.GetString();
|
||||||
|
if (lexrc.next())
|
||||||
|
flags = lexrc.GetString();
|
||||||
|
command = subst(command, "$$FName", "'$$FName'");
|
||||||
|
command = subst(command, "$$BaseName", "'$$BaseName'");
|
||||||
|
command = subst(command, "$$OutName", "'$$OutName'");
|
||||||
|
Converter::Add(from, to, command, flags);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RC_VIEWER:
|
||||||
|
{
|
||||||
|
string format, command;
|
||||||
|
if (lexrc.next())
|
||||||
|
format = lexrc.GetString();
|
||||||
|
if (lexrc.next())
|
||||||
|
command = lexrc.GetString();
|
||||||
|
command = subst(command, "$$FName", "'$$FName'");
|
||||||
|
Formats::SetViewer(format, command);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case RC_LAST: break; // this is just a dummy
|
case RC_LAST: break; // this is just a dummy
|
||||||
}
|
}
|
||||||
|
43
src/menus.C
43
src/menus.C
@ -51,10 +51,12 @@
|
|||||||
#include "insets/insetref.h"
|
#include "insets/insetref.h"
|
||||||
#include "insets/insettabular.h"
|
#include "insets/insettabular.h"
|
||||||
#include "tabular.h"
|
#include "tabular.h"
|
||||||
|
#include "exporter.h"
|
||||||
|
|
||||||
#include "frontends/Dialogs.h"
|
#include "frontends/Dialogs.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using std::pair;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::max;
|
using std::max;
|
||||||
using std::min;
|
using std::min;
|
||||||
@ -499,9 +501,22 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
|
fl_setpup_shortcut(SubFileImport, 34, scex(_("FIM|Dd#d#D")));
|
||||||
|
|
||||||
// Export sub-menu
|
// Export sub-menu
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
int SubFileExport = fl_defpup(FL_ObjWin(ob),
|
||||||
|
_("Export%t"));
|
||||||
|
vector<pair<string,string> > formats =
|
||||||
|
Exporter::GetExportableFormats(tmpbuffer);
|
||||||
|
for (vector<pair<string,string> >::size_type i = 0;
|
||||||
|
i < formats.size(); ++i) {
|
||||||
|
string entry = _("as ")
|
||||||
|
+ formats[i].second
|
||||||
|
+ "%x" + tostr(1000+i);
|
||||||
|
fl_addtopup(SubFileExport, entry.c_str());
|
||||||
|
}
|
||||||
|
#else
|
||||||
// remember to make this handle linuxdoc too.
|
// remember to make this handle linuxdoc too.
|
||||||
// and now docbook also.
|
// and now docbook also.
|
||||||
|
|
||||||
int SubFileExport = 0;
|
int SubFileExport = 0;
|
||||||
if (!LinuxDoc && !DocBook)
|
if (!LinuxDoc && !DocBook)
|
||||||
SubFileExport= fl_defpup(FL_ObjWin(ob),
|
SubFileExport= fl_defpup(FL_ObjWin(ob),
|
||||||
@ -528,7 +543,6 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
"|as PostScript...%x42"
|
"|as PostScript...%x42"
|
||||||
"|as Ascii Text...%x43"
|
"|as Ascii Text...%x43"
|
||||||
"|as HTML...%x44"));
|
"|as HTML...%x44"));
|
||||||
|
|
||||||
fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
|
fl_setpup_shortcut(SubFileExport, 40, scex(_("FEX|Ll#l#L")));
|
||||||
fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
|
fl_setpup_shortcut(SubFileExport, 41, scex(_("FEX|Dd#d#D")));
|
||||||
fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
|
fl_setpup_shortcut(SubFileExport, 42, scex(_("FEX|Pp#p#P")));
|
||||||
@ -538,6 +552,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
if (!LinuxDoc && !DocBook) {
|
if (!LinuxDoc && !DocBook) {
|
||||||
fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
|
fl_setpup_shortcut(SubFileExport, 45, scex(_("FEX|mM#m#M")));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int FileMenu = fl_defpup(FL_ObjWin(ob),
|
int FileMenu = fl_defpup(FL_ObjWin(ob),
|
||||||
_("New..."
|
_("New..."
|
||||||
@ -605,6 +620,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
if ( lyxrc.linuxdoc_to_lyx_command == "none")
|
if ( lyxrc.linuxdoc_to_lyx_command == "none")
|
||||||
fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
|
fl_setpup_mode(SubFileImport, 34, FL_PUP_GREY);
|
||||||
|
|
||||||
|
#ifndef NEW_EXPORT
|
||||||
if (!hasLaTeX) {
|
if (!hasLaTeX) {
|
||||||
// Disable export dvi and export postscript
|
// Disable export dvi and export postscript
|
||||||
fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
|
fl_setpup_mode(SubFileExport, 41, FL_PUP_GREY);
|
||||||
@ -617,6 +633,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
// Disable export HTML
|
// Disable export HTML
|
||||||
fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
|
fl_setpup_mode(SubFileExport, 44, FL_PUP_GREY);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// xgettext:no-c-format
|
// xgettext:no-c-format
|
||||||
fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
|
fl_addtopup(FileMenu, _("|Import%m"), SubFileImport);
|
||||||
@ -660,10 +677,17 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
|
case 5: tmpfunc->Dispatch(LFUN_MENUWRITE); break;
|
||||||
case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
|
case 6: tmpfunc->Dispatch(LFUN_MENUWRITEAS); break;
|
||||||
case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
|
case 7: tmpfunc->Dispatch(LFUN_MENURELOAD); break;
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
case 8: tmpfunc->Dispatch(LFUN_PREVIEW, "dvi"); break;
|
||||||
|
case 9: tmpfunc->Dispatch(LFUN_PREVIEW, "ps"); break;
|
||||||
|
case 10: tmpfunc->Dispatch(LFUN_UPDATE, "dvi"); break;
|
||||||
|
case 11: tmpfunc->Dispatch(LFUN_UPDATE, "ps"); break;
|
||||||
|
#else
|
||||||
case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
|
case 8: tmpfunc->Dispatch(LFUN_PREVIEW); break;
|
||||||
case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
|
case 9: tmpfunc->Dispatch(LFUN_PREVIEWPS); break;
|
||||||
case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
|
case 10: tmpfunc->Dispatch(LFUN_RUNLATEX); break;
|
||||||
case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
|
case 11: tmpfunc->Dispatch(LFUN_RUNDVIPS); break;
|
||||||
|
#endif
|
||||||
case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
|
case 12: tmpfunc->Dispatch(LFUN_BUILDPROG); break;
|
||||||
case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
|
case 13: tmpfunc->Dispatch(LFUN_MENUPRINT); break;
|
||||||
case 14: tmpfunc->Dispatch(LFUN_FAX); break;
|
case 14: tmpfunc->Dispatch(LFUN_FAX); break;
|
||||||
@ -678,6 +702,20 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
break;
|
break;
|
||||||
case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
|
case 34: tmpfunc->Dispatch(LFUN_IMPORT, "linuxdoc");
|
||||||
break;
|
break;
|
||||||
|
#ifdef NEW_EXPORT
|
||||||
|
case 18:
|
||||||
|
tmpfunc->Dispatch(LFUN_QUIT);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (choice >= 1000)
|
||||||
|
tmpfunc->Dispatch(LFUN_EXPORT,
|
||||||
|
formats[choice-1000].first.c_str());
|
||||||
|
else
|
||||||
|
men->currentView()
|
||||||
|
->buffer(bufferlist
|
||||||
|
.loadLyXFile((*lastfiles)[choice - 18]));
|
||||||
|
break;
|
||||||
|
#else
|
||||||
case 16: // export menu
|
case 16: // export menu
|
||||||
case 40:
|
case 40:
|
||||||
if (!LinuxDoc && !DocBook)
|
if (!LinuxDoc && !DocBook)
|
||||||
@ -705,6 +743,7 @@ void Menus::ShowFileMenu(FL_OBJECT * ob, long)
|
|||||||
->buffer(bufferlist
|
->buffer(bufferlist
|
||||||
.loadLyXFile((*lastfiles)[choice - 18]));
|
.loadLyXFile((*lastfiles)[choice - 18]));
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
fl_freepup(SubFileImport);
|
fl_freepup(SubFileImport);
|
||||||
fl_freepup(SubFileExport);
|
fl_freepup(SubFileExport);
|
||||||
|
@ -957,6 +957,18 @@ ChangeExtension(string const & oldname, string const & extension)
|
|||||||
return CleanupPath(oldname.substr(0, last_dot) + ext);
|
return CleanupPath(oldname.substr(0, last_dot) + ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the extension of the file (not including the .)
|
||||||
|
string GetExtension(string const & name)
|
||||||
|
{
|
||||||
|
string::size_type last_slash = name.rfind('/');
|
||||||
|
string::size_type last_dot = name.rfind('.');
|
||||||
|
if (last_dot != string::npos &&
|
||||||
|
(last_slash == string::npos || last_dot > last_slash))
|
||||||
|
return name.substr(last_dot + 1,
|
||||||
|
name.length() - (last_dot + 1));
|
||||||
|
else
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a nice compact path for displaying
|
// Creates a nice compact path for displaying
|
||||||
string const
|
string const
|
||||||
|
@ -139,6 +139,9 @@ string const AddPath(string const & path, string const & path2);
|
|||||||
string const
|
string const
|
||||||
ChangeExtension(string const & oldname, string const & extension);
|
ChangeExtension(string const & oldname, string const & extension);
|
||||||
|
|
||||||
|
/// Return the extension of the file (not including the .)
|
||||||
|
string GetExtension(string const & name);
|
||||||
|
|
||||||
/// Create absolute path. If impossible, don't do anything
|
/// Create absolute path. If impossible, don't do anything
|
||||||
string const ExpandPath(string const & path);
|
string const ExpandPath(string const & path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user