]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/Liason.C
fix typo that put too many include paths for most people
[lyx.git] / src / frontends / Liason.C
index c0a4b31fc3de67765c1283d952d0630151a96c9c..ee8d456c831cfadfaea7c5f4daf122e2f088e201 100644 (file)
@@ -1,10 +1,10 @@
 /* This file is part of
- * ====================================================== 
- * 
+ * ======================================================
+ *
  *           LyX, The Document Processor
- *        
+ *
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
  * ====================================================== */
 
 #endif
 
 #include "Liason.h"
+#include "lyxrc.h"
+#include "PrinterParams.h"
+
 #include "LyXView.h"
 #include "BufferView.h"
 #include "buffer.h"
-#include "lyxrc.h"
-#include "PrinterParams.h"
-#include "lyx_gui_misc.h"
+#include "exporter.h"
+#include "converter.h"
+
+#include "support/LAssert.h"
 #include "support/lstrings.h"
 #include "support/filetools.h"
 #include "support/path.h"
-#include "exporter.h"
-#include "converter.h"
-#include "minibuffer.h"
-#include "support/syscall.h"
+#include "support/systemcall.h"
 
 using std::endl;
 
 extern LyXRC lyxrc;
-#ifndef NEW_EXPORT
-extern bool RunScript(Buffer * buffer, bool wait, string const & command,
-                     string const & orgname = string(), bool need_shell=true);
-#endif
 
-#ifdef CXX_WORKING_NAMESPACES
-namespace Liason 
-{
-#endif
+namespace Liason {
 
 PrinterParams getPrinterParams(Buffer * buffer)
 {
@@ -51,13 +45,10 @@ PrinterParams getPrinterParams(Buffer * buffer)
 }
 
 
-bool printBuffer(Buffer * buffer, PrinterParams const & pp) 
+bool printBuffer(Buffer * buffer, PrinterParams const & pp)
 {
-#ifndef NEW_EXPORT
-       bool result(false);
-#endif
        string command(lyxrc.print_command + ' ');
-       
+
        if (pp.target == PrinterParams::PRINTER
            && lyxrc.print_adapt_output  // dvips wants a printer name
            && !pp.printer_name.empty()) {// printer name given
@@ -74,7 +65,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
        case PrinterParams::ODD:
                command += lyxrc.print_oddpage_flag + ' ';
                break;
-    
+
        default:
                // only option left is print all of them
                break;
@@ -110,15 +101,14 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                command += lyxrc.print_extra_options + ' ';
        }
 
-       command += Converter::dvips_options(buffer) + ' ';
+       command += converters.dvips_options(buffer) + ' ';
 
-#ifdef NEW_EXPORT
        if (!Exporter::Export(buffer, "dvi", true))
                return false;
 
        // Push directory path.
-       string path = OnlyPath(buffer->fileName());
-       if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
+       string path = buffer->filePath();
+       if (lyxrc.use_tempdir || !IsDirWriteable(path)) {
                path = buffer->tmppath;
        }
        Path p(path);
@@ -127,7 +117,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
        // 1. we print to a file
        // 2. we print direct to a printer
        // 3. we print using a spool command (print to file first)
-       Systemcalls one;
+       Systemcall one;
        int res = 0;
        string dviname = ChangeExtension(buffer->getLatexName(true), "dvi");
        switch (pp.target) {
@@ -145,13 +135,14 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                        command2 += QuoteName(psname);
                        // First run dvips.
                        // If successful, then spool command
-                       res = one.startscript(Systemcalls::System, command);
+                       res = one.startscript(Systemcall::Wait, command);
                        if (res == 0)
-                               res = one.startscript(Systemcalls::SystemDontWait,
+                               res = one.startscript(Systemcall::DontWait,
                                                      command2);
                } else
                        // case 2
-                       res = one.startscript(Systemcalls::SystemDontWait, command);
+                       res = one.startscript(Systemcall::DontWait,
+                                             command + QuoteName(dviname));
                break;
 
        case PrinterParams::FILE:
@@ -159,69 +150,17 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                command += lyxrc.print_to_file
                        + QuoteName(MakeAbsPath(pp.file_name, path));
                command += ' ' + QuoteName(dviname);
-               res = one.startscript(Systemcalls::SystemDontWait, command);
+               res = one.startscript(Systemcall::DontWait, command);
                break;
        }
        return res == 0;
-#else
-       // Push directory path if necessary.
-       // PS file should go where the source file is unless it's a
-       // read-only directory in which case we write it to tmpdir.
-       // All temporary files go in tmpdir (like spool files).
-       string path = OnlyPath(buffer->fileName());
-       if ((pp.target != PrinterParams::FILE
-            && lyxrc.use_tempdir)
-           || (IsDirWriteable(path) < 1)) {
-               path = buffer->tmppath;
-       }
-       Path p(path);
-
-       // there are three cases here:
-       // 1. we print to a file
-       // 2. we print direct to a printer
-       // 3. we print using a spool command (print to file first)
-       switch (pp.target) {
-       case PrinterParams::PRINTER:
-               if (!lyxrc.print_spool_command.empty()) {
-                               // case 3
-                       command += lyxrc.print_to_file
-                               + QuoteName(pp.file_name);
-                       string command2 = lyxrc.print_spool_command
-                               + ' ';
-                       if (!pp.printer_name.empty()) {
-                               command2 += lyxrc.print_spool_printerprefix
-                                       + pp.printer_name;
-                       }
-                               // First run dvips.
-                               // If successful, then spool command
-                       if (result = RunScript(buffer, true, command)) {
-                               result = RunScript(buffer, false,
-                                                  command2,
-                                                  QuoteName(pp.file_name));
-                       }
-               } else {
-                               // case 2
-                       result = RunScript(buffer, false, command);
-               }
-               break;
-
-       case PrinterParams::FILE:
-               // case 1
-               command += lyxrc.print_to_file
-                       + QuoteName(MakeAbsPath(pp.file_name, path));
-               result = RunScript(buffer, false, command);
-               break;
-       }
-       return result;
-#endif
 }
 
-void setMinibuffer(LyXView * lv, char const * msg)
-{
-       lv->getMiniBuffer()->Set(msg);
-}
 
-#ifdef CXX_WORKING_NAMESPACES
+void setMinibuffer(LyXView * lv, string const & msg)
+{
+       lyx::Assert(lv);
+       lv->message(msg);
 }
-#endif
 
+} // namespace Liason