#include "bufferview_funcs.h"
#include "LaTeX.h"
#include "LyXView.h"
-#include "minibuffer.h"
#include "lyx_gui_misc.h"
#include "lyx_cb.h" // ShowMessage()
#include "support/lyxfunctional.h"
+#include "gettext.h"
using std::vector;
using std::queue;
using std::reverse;
using std::sort;
-static string const token_from("$$i");
-static string const token_base("$$b");
-static string const token_to("$$o");
+namespace {
+
+string const token_from("$$i");
+string const token_base("$$b");
+string const token_to("$$o");
//////////////////////////////////////////////////////////////////////////////
-static inline
+inline
string const add_options(string const & command, string const & options)
{
string head;
return head + ' ' + options + ' ' + tail;
}
+} // namespace anon
+
//////////////////////////////////////////////////////////////////////////////
bool Format::dummy() const
{
FormatList::const_iterator cit =
find_if(formatlist.begin(), formatlist.end(),
- compare_memfun(&Format::name, name));
+ lyx::compare_memfun(&Format::name, name));
if (cit != formatlist.end())
return &(*cit);
else
{
FormatList::const_iterator cit =
find_if(formatlist.begin(), formatlist.end(),
- compare_memfun(&Format::name, name));
+ lyx::compare_memfun(&Format::name, name));
if (cit != formatlist.end())
return cit - formatlist.begin();
else
{
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
- compare_memfun(&Format::name, name));
+ lyx::compare_memfun(&Format::name, name));
if (it == formatlist.end())
formatlist.push_back(Format(name, extension, prettyname,
shortcut, ""));
{
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
- compare_memfun(&Format::name, name));
+ lyx::compare_memfun(&Format::name, name));
if (it != formatlist.end())
formatlist.erase(it);
}
Add(name);
FormatList::iterator it =
find_if(formatlist.begin(), formatlist.end(),
- compare_memfun(&Format::name, name));
+ lyx::compare_memfun(&Format::name, name));
if (it != formatlist.end())
it->setViewer(command);
}
if (format_name == "dvi" &&
!lyxrc.view_dvi_paper_option.empty()) {
command += " " + lyxrc.view_dvi_paper_option;
- command += " " + converters.dvi_papersize(buffer);
+ string paper_size = converters.papersize(buffer);
+ if (paper_size == "letter")
+ paper_size = "us";
+ command += " " + paper_size;
if (buffer->params.orientation
== BufferParams::ORIENTATION_LANDSCAPE)
command += 'r';
if (conv.from == "dvi" && conv.to == "ps")
command = add_options(command,
dvips_options(buffer));
+ else if (conv.from == "dvi" && prefixIs(conv.to, "pdf"))
+ command = add_options(command,
+ dvipdfm_options(buffer));
lyxerr << "Calling " << command << endl;
if (buffer)
if (bv) {
ProhibitInput(bv);
- bv->owner()->getMiniBuffer()->Set(_("Running LaTeX..."));
+ bv->owner()->message(_("Running LaTeX..."));
// Remove all error insets
need_redraw = bv->removeAutoInsets();
}
TeXErrors terr;
LaTeX latex(command, name, buffer->filepath);
int result = latex.run(terr,
- bv ? bv->owner()->getMiniBuffer() : 0);
+ bv ? bv->owner()->getLyXFunc() : 0);
if (bv) {
}
-string const Converters::dvi_papersize(Buffer const * buffer)
+string const Converters::papersize(Buffer const * buffer)
{
char real_papersize = buffer->params.papersize;
if (real_papersize == BufferParams::PAPER_DEFAULT)
return "legal";
case BufferParams::PAPER_USLETTER:
default:
- return "us";
+ return "letter";
}
}
result += ' ' + buffer->params.paperwidth;
result += ',' + buffer->params.paperheight;
} else {
- string paper_option = dvi_papersize(buffer);
- if (paper_option == "us")
- paper_option = "letter";
+ string paper_option = papersize(buffer);
if (paper_option != "letter" ||
buffer->params.orientation != BufferParams::ORIENTATION_LANDSCAPE) {
// dvips won't accept -t letter -t landscape. In all other
result += ' ' + paper_option;
}
}
- if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
+ if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE &&
+ buffer->params.papersize2 != BufferParams::VM_PAPER_CUSTOM)
result += ' ' + lyxrc.print_landscape_flag;
return result;
}
+
+string const Converters::dvipdfm_options(Buffer const * buffer)
+{
+ string result;
+ if (!buffer)
+ return result;
+
+ if (buffer->params.papersize2 != BufferParams::VM_PAPER_CUSTOM) {
+ string paper_size = papersize(buffer);
+ if (paper_size != "b5" && paper_size != "foolscap")
+ result = "-p "+ paper_size;
+
+ if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
+ result += " -l";
+ }
+
+ return result;
+}
+
+
vector<Converters::Vertex> Converters::vertices;