]> git.lyx.org Git - lyx.git/blobdiff - src/exporter.C
more cursor dispatch
[lyx.git] / src / exporter.C
index 49e59e194951a16fd7358f2829e612419475412a..a58c23e6a1cf4369f9fb64d9a6fb59998ae05ebe 100644 (file)
@@ -4,37 +4,51 @@
  * Licence details can be found in the file COPYING.
  *
  * \author unknown
+ * \author Alfredo Braunstein
+ * \author Lars Gullik Bjønnes
+ * \author Jean Marc Lasgouttes
+ * \author Angus Leeming
+ * \author John Levon
+ * \author André Pönitz
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 
 #include "exporter.h"
+
 #include "buffer.h"
 #include "buffer_funcs.h"
-#include "lyx_cb.h" //ShowMessage()
-#include "support/filetools.h"
-#include "lyxrc.h"
+#include "bufferparams.h"
 #include "converter.h"
 #include "format.h"
-#include "frontends/Alert.h"
 #include "gettext.h"
-#include "BufferView.h"
+#include "lyxrc.h"
+#include "output_plaintext.h"
+#include "outputparams.h"
+#include "frontends/Alert.h"
+
+#include "support/filetools.h"
 
-#include <algorithm>
+using lyx::support::AddName;
+using lyx::support::bformat;
+using lyx::support::ChangeExtension;
+using lyx::support::contains;
+using lyx::support::MakeDisplayPath;
 
-using std::vector;
 using std::find;
+using std::string;
+using std::vector;
 
 
 namespace {
 
-vector<string> const Backends(Buffer const * buffer)
+vector<string> const Backends(Buffer const & buffer)
 {
        vector<string> v;
-       if (buffer->params.getLyXTextClass().isTeXClassAvailable())
-               v.push_back(BufferFormat(*buffer));
+       if (buffer.params().getLyXTextClass().isTeXClassAvailable())
+               v.push_back(BufferFormat(buffer));
        v.push_back("text");
        return v;
 }
@@ -46,17 +60,17 @@ bool Exporter::Export(Buffer * buffer, string const & format,
                      bool put_in_tempdir, string & result_file)
 {
        string backend_format;
-       LatexRunParams runparams;
-       runparams.flavor = LatexRunParams::LATEX;
-       vector<string> backends = Backends(buffer);
+       OutputParams runparams;
+       runparams.flavor = OutputParams::LATEX;
+       runparams.linelen = lyxrc.ascii_linelen;
+       vector<string> backends = Backends(*buffer);
        if (find(backends.begin(), backends.end(), format) == backends.end()) {
                for (vector<string>::const_iterator it = backends.begin();
                     it != backends.end(); ++it) {
                        Graph::EdgePath p =
                                converters.getPath(*it, format);
                        if (!p.empty()) {
-                               if (converters.usePdflatex(p))
-                                       runparams.flavor = LatexRunParams::PDFLATEX;
+                               runparams.flavor = converters.getFlavor(p);
                                backend_format = *it;
                                break;
                        }
@@ -71,20 +85,24 @@ bool Exporter::Export(Buffer * buffer, string const & format,
                backend_format = format;
 
        string filename = buffer->getLatexName(false);
-       if (!buffer->tmppath.empty())
-               filename = AddName(buffer->tmppath, filename);
+       if (!buffer->temppath().empty())
+               filename = AddName(buffer->temppath(), filename);
        filename = ChangeExtension(filename,
                                   formats.extension(backend_format));
 
        // Ascii backend
        if (backend_format == "text")
-               buffer->writeFileAscii(filename, lyxrc.ascii_linelen);
+               writeFileAscii(*buffer, filename, runparams);
        // Linuxdoc backend
-       else if (buffer->isLinuxDoc())
-               buffer->makeLinuxDocFile(filename, !put_in_tempdir);
+       else if (buffer->isLinuxDoc()) {
+               runparams.nice = !put_in_tempdir;
+               buffer->makeLinuxDocFile(filename, runparams);
+       }
        // Docbook backend
-       else if (buffer->isDocBook())
-               buffer->makeDocBookFile(filename, !put_in_tempdir);
+       else if (buffer->isDocBook()) {
+               runparams.nice = !put_in_tempdir;
+               buffer->makeDocBookFile(filename, runparams);
+       }
        // LaTeX backend
        else if (backend_format == format) {
                runparams.nice = true;
@@ -106,11 +124,10 @@ bool Exporter::Export(Buffer * buffer, string const & format,
                return false;
 
        if (!put_in_tempdir)
-               ShowMessage(buffer,
-                           _("Document exported as ")
-                           + formats.prettyName(format)
-                           + _(" to file `")
-                           + MakeDisplayPath(result_file) +'\'');
+               buffer->message(_("Document exported as ")
+                                     + formats.prettyName(format)
+                                     + _(" to file `")
+                                     + MakeDisplayPath(result_file) +'\'');
        return true;
 }
 
@@ -128,11 +145,11 @@ bool Exporter::Preview(Buffer * buffer, string const & format)
        string result_file;
        if (!Export(buffer, format, true, result_file))
                return false;
-       return formats.view(buffer, result_file, format);
+       return formats.view(*buffer, result_file, format);
 }
 
 
-bool Exporter::IsExportable(Buffer const * buffer, string const & format)
+bool Exporter::IsExportable(Buffer const & buffer, string const & format)
 {
        vector<string> backends = Backends(buffer);
        for (vector<string>::const_iterator it = backends.begin();
@@ -144,7 +161,7 @@ bool Exporter::IsExportable(Buffer const * buffer, string const & format)
 
 
 vector<Format const *> const
-Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable)
+Exporter::GetExportableFormats(Buffer const & buffer, bool only_viewable)
 {
        vector<string> backends = Backends(buffer);
        vector<Format const *> result =
@@ -157,4 +174,3 @@ Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable)
        }
        return result;
 }
-