From dd19aa6e6336c3cfa22d927170eb14c3c35d1f9e Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Sun, 28 Jan 2001 16:52:27 +0000 Subject: [PATCH] Add paper options when invoking dvipdfm. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1408 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 4 ++++ src/converter.C | 39 ++++++++++++++++++++++++++++++++------- src/converter.h | 4 +++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 24255bf70a..c7d00ee16f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-01-27 Dekel Tsur + + * converter.C (dvipdfm_options): New method. + 2001-01-26 Dekel Tsur * vspace.C (isValidLength): Fix for empty input string. diff --git a/src/converter.C b/src/converter.C index 01fe135b0b..cb1b84653b 100644 --- a/src/converter.C +++ b/src/converter.C @@ -173,7 +173,10 @@ bool Formats::View(Buffer const * buffer, string const & filename, 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'; @@ -606,6 +609,9 @@ bool Converters::Convert(Buffer const * buffer, 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) @@ -872,7 +878,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) } -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) @@ -893,7 +899,7 @@ string const Converters::dvi_papersize(Buffer const * buffer) return "legal"; case BufferParams::PAPER_USLETTER: default: - return "us"; + return "letter"; } } @@ -914,9 +920,7 @@ string const Converters::dvips_options(Buffer const * buffer) 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 @@ -925,11 +929,32 @@ string const Converters::dvips_options(Buffer const * buffer) 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::vertices; diff --git a/src/converter.h b/src/converter.h index 013370c393..0b1e1b9d1d 100644 --- a/src/converter.h +++ b/src/converter.h @@ -215,10 +215,12 @@ public: string const & from_file, string const & to_file_base, string const & from_format, string const & to_format); /// - string const dvi_papersize(Buffer const * buffer); + string const papersize(Buffer const * buffer); /// string const dvips_options(Buffer const * buffer); /// + string const dvipdfm_options(Buffer const * buffer); + /// void Update(Formats const & formats); /// void UpdateLast(Formats const & formats);