X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLyXSendto.C;h=5f672ac07bd0e4da087e725e2aaf06e06c7d0205;hb=5702f22ef0ea3d167fc5f327002d7006eef657b4;hp=271c6a33be599e7b82474bac434d5a44dc6e382f;hpb=535dd32c4ca49739583b37293e28db48ac1ecec3;p=lyx.git diff --git a/src/LyXSendto.C b/src/LyXSendto.C index 271c6a33be..5f672ac07b 100644 --- a/src/LyXSendto.C +++ b/src/LyXSendto.C @@ -10,33 +10,45 @@ #include "buffer.h" #include "lyx_gui_misc.h" #include "support/syscall.h" +#include "support/lstrings.h" #include "gettext.h" -#include "lyx_cb.h" +#include "bufferview_funcs.h" +#include "exporter.h" +#include "BufferView.h" -extern FD_form_sendto *fd_form_sendto; -extern BufferView *current_view; -extern int MakeDVIOutput(Buffer *buffer); -extern bool MenuRunDvips(Buffer *buffer, bool wait); +extern FD_form_sendto * fd_form_sendto; +extern BufferView * current_view; +extern int MakeLaTeXOutput(Buffer * buffer); +extern bool CreatePostscript(Buffer * buffer, bool wait); // Whereas this feature is under the menu item File->Export->Custom, // I kept the old name sendto in the code because I am lazy (JMarc) void MenuSendto() { + static int ow = -1; + static int oh; + // do this only if the command is empty if (!fl_get_input(fd_form_sendto->input_cmd) && - !lyxrc->custom_export_command.empty()) + !lyxrc.custom_export_command.empty()) fl_set_input(fd_form_sendto->input_cmd, - lyxrc->custom_export_command.c_str()); + lyxrc.custom_export_command.c_str()); if (fd_form_sendto->form_sendto->visible) { fl_raise_form(fd_form_sendto->form_sendto); } else { fl_show_form(fd_form_sendto->form_sendto, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, + FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT, _("Send Document to Command")); + if (ow < 0) { + ow = fd_form_sendto->form_sendto->w; + oh = fd_form_sendto->form_sendto->h; + } + fl_set_form_minsize(fd_form_sendto->form_sendto, ow, oh); } } + void SendtoApplyCB(FL_OBJECT *, long) { if (!current_view->available()) @@ -45,17 +57,7 @@ void SendtoApplyCB(FL_OBJECT *, long) string command = fl_get_input(fd_form_sendto->input_cmd); if (command.empty()) return; - Buffer *buffer = current_view->currentBuffer(); - if (fl_get_button(fd_form_sendto->radio_ftype_dvi) || - fl_get_button(fd_form_sendto->radio_ftype_ps)) { - ProhibitInput(); - // Generate dvi file and check if there are errors in the .lyx file - if (MakeDVIOutput(buffer) > 0) { - AllowInput(); - return; - } - AllowInput(); - } + Buffer * buffer = current_view->buffer(); string ftypeext; if (fl_get_button(fd_form_sendto->radio_ftype_lyx)) ftypeext = ".lyx"; @@ -66,43 +68,45 @@ void SendtoApplyCB(FL_OBJECT *, long) else if (fl_get_button(fd_form_sendto->radio_ftype_ascii)) ftypeext = ".txt"; else { - ftypeext = ".ps_tmp"; - if (!MenuRunDvips(buffer, true)) { - return; - } + ftypeext = ".ps"; + if (!Exporter::Export(buffer, "ps", true)) + return; } - string fname = SpaceLess(ChangeExtension(buffer->getFileName(), - ftypeext, true)); + + string const fname = OnlyFilename(ChangeExtension(buffer->getLatexName(), + ftypeext)); if (!contains(command, "$$FName")) command = "( " + command + " ) <$$FName"; - subst(command, "$$FName",fname); + command = subst(command, "$$FName", fname); command += " &"; // execute in background // push directorypath, if necessary - string path = OnlyPath(buffer->getFileName()); - if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){ + string path = OnlyPath(buffer->fileName()); + if (lyxrc.use_tempdir || !IsDirWriteable(path)){ path = buffer->tmppath; } Path p(path); // save the .lyx file in tmp_dir if this filetype is requested if (fl_get_button(fd_form_sendto->radio_ftype_lyx)) - buffer->writeFile(fname,true); + buffer->writeFile(fname, true); // if the .tex file is requested save it to the tempdir - // as now we don't do the MakeDVIOutput anymore + // as now we don't do the MakeLaTeXOutput anymore if (fl_get_button(fd_form_sendto->radio_ftype_latex)) - buffer->makeLaTeXFile(fname,path,false); + buffer->makeLaTeXFile(fname, path, false); // create the .txt file in tmp_dir if this filetype is requested if (fl_get_button(fd_form_sendto->radio_ftype_ascii)) - buffer->writeFileAscii(fname, lyxrc->ascii_linelen); + buffer->writeFileAscii(fname, lyxrc.ascii_linelen); Systemcalls one(Systemcalls::System, command); } + void SendtoCancelCB(FL_OBJECT *, long) { fl_hide_form(fd_form_sendto->form_sendto); } -void SendtoOKCB(FL_OBJECT *ob, long data) + +void SendtoOKCB(FL_OBJECT * ob, long data) { - SendtoCancelCB(ob,data); - SendtoApplyCB(ob,data); + SendtoCancelCB(ob, data); + SendtoApplyCB(ob, data); }