1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
13 #include "bufferparams.h"
14 #include "tex-strings.h"
21 #include "lyxtextclasslist.h"
27 #include "support/lyxalgo.h" // for lyx::count
28 #include "support/lyxlib.h"
29 #include "support/lstrings.h"
30 #include "support/types.h"
32 #include "frontends/Alert.h"
37 using namespace lyx::support;
44 BufferParams::BufferParams()
45 // Initialize textclass to point to article. if `first' is
46 // true in the returned pair, then `second' is the textclass
47 // number; if it is false, second is 0. In both cases, second
49 : textclass(textclasslist.NumberOfClass("article").second)
51 paragraph_separation = PARSEP_INDENT;
52 defskip = VSpace(VSpace::MEDSKIP);
53 quotes_language = InsetQuotes::EnglishQ;
54 quotes_times = InsetQuotes::DoubleQ;
58 papersize = PAPER_DEFAULT;
59 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
60 paperpackage = PACKAGE_NONE;
61 orientation = ORIENTATION_PORTRAIT;
63 use_amsmath = AMS_AUTO;
65 use_numerical_citations = false;
66 tracking_changes = false;
69 language = default_language;
72 graphicsDriver = "default";
73 sides = LyXTextClass::OneSide;
75 pagestyle = "default";
77 for (int iter = 0; iter < 4; ++iter) {
78 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
79 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
84 string const BufferParams::readToken(LyXLex & lex, string const & token)
86 if (token == "\\textclass") {
88 string const classname = lex.getString();
89 pair<bool, lyx::textclass_type> pp =
90 textclasslist.NumberOfClass(classname);
92 textclass = pp.second;
97 if (!getLyXTextClass().isTeXClassAvailable()) {
98 string msg = bformat(_("The document uses a missing "
99 "TeX class \"%1$s\".\n"), classname);
100 Alert::warning(_("Document class not available"),
101 msg + _("LyX will not be able to produce output."));
103 } else if (token == "\\begin_preamble") {
105 } else if (token == "\\options") {
107 options = lex.getString();
108 } else if (token == "\\language") {
110 } else if (token == "\\inputencoding") {
112 inputenc = lex.getString();
113 } else if (token == "\\graphics") {
114 readGraphicsDriver(lex);
115 } else if (token == "\\fontscheme") {
117 fonts = lex.getString();
118 } else if (token == "\\paragraph_separation") {
119 int tmpret = lex.findToken(string_paragraph_separation);
122 paragraph_separation =
123 static_cast<PARSEP>(tmpret);
124 } else if (token == "\\defskip") {
126 defskip = VSpace(lex.getString());
127 } else if (token == "\\quotes_language") {
128 // FIXME: should be params.readQuotes()
129 int tmpret = lex.findToken(string_quotes_language);
132 InsetQuotes::quote_language tmpl =
133 InsetQuotes::EnglishQ;
136 tmpl = InsetQuotes::EnglishQ;
139 tmpl = InsetQuotes::SwedishQ;
142 tmpl = InsetQuotes::GermanQ;
145 tmpl = InsetQuotes::PolishQ;
148 tmpl = InsetQuotes::FrenchQ;
151 tmpl = InsetQuotes::DanishQ;
154 quotes_language = tmpl;
155 } else if (token == "\\quotes_times") {
156 // FIXME: should be params.readQuotes()
158 switch (lex.getInteger()) {
160 quotes_times = InsetQuotes::SingleQ;
163 quotes_times = InsetQuotes::DoubleQ;
166 } else if (token == "\\papersize") {
167 int tmpret = lex.findToken(string_papersize);
171 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
172 } else if (token == "\\paperpackage") {
173 int tmpret = lex.findToken(string_paperpackages);
176 paperpackage = PACKAGE_NONE;
178 paperpackage = PAPER_PACKAGES(tmpret);
179 } else if (token == "\\use_geometry") {
181 use_geometry = lex.getInteger();
182 } else if (token == "\\use_amsmath") {
184 use_amsmath = static_cast<AMS>(
186 } else if (token == "\\use_natbib") {
188 use_natbib = lex.getInteger();
189 } else if (token == "\\use_numerical_citations") {
191 use_numerical_citations = lex.getInteger();
192 } else if (token == "\\tracking_changes") {
194 tracking_changes = lex.getInteger();
195 } else if (token == "\\author") {
197 istringstream ss(STRCONV(lex.getString()));
200 author_map.push_back(authorlist.record(a));
201 } else if (token == "\\paperorientation") {
202 int tmpret = lex.findToken(string_orientation);
206 static_cast<PAPER_ORIENTATION>(tmpret);
207 } else if (token == "\\paperwidth") {
209 paperwidth = lex.getString();
210 } else if (token == "\\paperheight") {
212 paperheight = lex.getString();
213 } else if (token == "\\leftmargin") {
215 leftmargin = lex.getString();
216 } else if (token == "\\topmargin") {
218 topmargin = lex.getString();
219 } else if (token == "\\rightmargin") {
221 rightmargin = lex.getString();
222 } else if (token == "\\bottommargin") {
224 bottommargin = lex.getString();
225 } else if (token == "\\headheight") {
227 headheight = lex.getString();
228 } else if (token == "\\headsep") {
230 headsep = lex.getString();
231 } else if (token == "\\footskip") {
233 footskip = lex.getString();
234 } else if (token == "\\paperfontsize") {
236 fontsize = rtrim(lex.getString());
237 } else if (token == "\\papercolumns") {
239 columns = lex.getInteger();
240 } else if (token == "\\papersides") {
242 switch (lex.getInteger()) {
244 case 1: sides = LyXTextClass::OneSide; break;
245 case 2: sides = LyXTextClass::TwoSides; break;
247 } else if (token == "\\paperpagestyle") {
249 pagestyle = rtrim(lex.getString());
250 } else if (token == "\\bullet") {
251 // FIXME: should be params.readBullets()
253 int const index = lex.getInteger();
255 int temp_int = lex.getInteger();
256 user_defined_bullets[index].setFont(temp_int);
257 temp_bullets[index].setFont(temp_int);
259 temp_int = lex.getInteger();
260 user_defined_bullets[index].setCharacter(temp_int);
261 temp_bullets[index].setCharacter(temp_int);
263 temp_int = lex.getInteger();
264 user_defined_bullets[index].setSize(temp_int);
265 temp_bullets[index].setSize(temp_int);
267 string const temp_str = lex.getString();
268 if (temp_str != "\\end_bullet") {
269 // this element isn't really necessary for
270 // parsing but is easier for humans
271 // to understand bullets. Put it back and
272 // set a debug message?
273 lex.printError("\\end_bullet expected, got" + temp_str);
274 //how can I put it back?
276 } else if (token == "\\bulletLaTeX") {
277 // The bullet class should be able to read this.
279 int const index = lex.getInteger();
281 string temp_str = lex.getString();
283 while (temp_str != "\\end_bullet") {
284 // this loop structure is needed when user
285 // enters an empty string since the first
286 // thing returned will be the \\end_bullet
288 // if the LaTeX entry has spaces. Each element
289 // therefore needs to be read in turn
292 temp_str = lex.getString();
295 user_defined_bullets[index].setText(sum_str);
296 temp_bullets[index].setText(sum_str);
297 } else if (token == "\\secnumdepth") {
299 secnumdepth = lex.getInteger();
300 } else if (token == "\\tocdepth") {
302 tocdepth = lex.getInteger();
303 } else if (token == "\\spacing") {
305 string const tmp = rtrim(lex.getString());
306 Spacing::Space tmp_space = Spacing::Default;
308 if (tmp == "single") {
309 tmp_space = Spacing::Single;
310 } else if (tmp == "onehalf") {
311 tmp_space = Spacing::Onehalf;
312 } else if (tmp == "double") {
313 tmp_space = Spacing::Double;
314 } else if (tmp == "other") {
316 tmp_space = Spacing::Other;
317 tmp_val = lex.getFloat();
319 lex.printError("Unknown spacing token: '$$Token'");
321 #if 0 // FIXME: Handled in lyx2lyx ?
322 // Small hack so that files written with klyx will be
325 par->params().spacing(Spacing(tmp_space, tmp_val));
327 spacing.set(tmp_space, tmp_val);
328 } else if (token == "\\float_placement") {
330 float_placement = lex.getString();
339 void BufferParams::writeFile(ostream & os) const
341 // The top of the file is written by the buffer.
342 // Prints out the buffer info into the .lyx file given by file
345 os << "\\textclass " << textclasslist[textclass].name() << '\n';
347 // then the the preamble
348 if (!preamble.empty()) {
349 // remove '\n' from the end of preamble
350 string const tmppreamble = rtrim(preamble, "\n");
351 os << "\\begin_preamble\n"
353 << "\n\\end_preamble\n";
357 if (!options.empty()) {
358 os << "\\options " << options << '\n';
361 /* then the text parameters */
362 if (language != ignore_language)
363 os << "\\language " << language->lang() << '\n';
364 os << "\\inputencoding " << inputenc
365 << "\n\\fontscheme " << fonts
366 << "\n\\graphics " << graphicsDriver << '\n';
368 if (!float_placement.empty()) {
369 os << "\\float_placement " << float_placement << '\n';
371 os << "\\paperfontsize " << fontsize << '\n';
373 spacing.writeFile(os);
375 os << "\\papersize " << string_papersize[papersize2]
376 << "\n\\paperpackage " << string_paperpackages[paperpackage]
377 << "\n\\use_geometry " << use_geometry
378 << "\n\\use_amsmath " << use_amsmath
379 << "\n\\use_natbib " << use_natbib
380 << "\n\\use_numerical_citations " << use_numerical_citations
381 << "\n\\paperorientation " << string_orientation[orientation]
383 if (!paperwidth.empty())
384 os << "\\paperwidth "
385 << VSpace(paperwidth).asLyXCommand() << '\n';
386 if (!paperheight.empty())
387 os << "\\paperheight "
388 << VSpace(paperheight).asLyXCommand() << '\n';
389 if (!leftmargin.empty())
390 os << "\\leftmargin "
391 << VSpace(leftmargin).asLyXCommand() << '\n';
392 if (!topmargin.empty())
394 << VSpace(topmargin).asLyXCommand() << '\n';
395 if (!rightmargin.empty())
396 os << "\\rightmargin "
397 << VSpace(rightmargin).asLyXCommand() << '\n';
398 if (!bottommargin.empty())
399 os << "\\bottommargin "
400 << VSpace(bottommargin).asLyXCommand() << '\n';
401 if (!headheight.empty())
402 os << "\\headheight "
403 << VSpace(headheight).asLyXCommand() << '\n';
404 if (!headsep.empty())
406 << VSpace(headsep).asLyXCommand() << '\n';
407 if (!footskip.empty())
409 << VSpace(footskip).asLyXCommand() << '\n';
410 os << "\\secnumdepth " << secnumdepth
411 << "\n\\tocdepth " << tocdepth
412 << "\n\\paragraph_separation "
413 << string_paragraph_separation[paragraph_separation]
414 << "\n\\defskip " << defskip.asLyXCommand()
415 << "\n\\quotes_language "
416 << string_quotes_language[quotes_language] << '\n';
417 switch (quotes_times) {
418 // An output operator for insetquotes would be nice
419 case InsetQuotes::SingleQ:
420 os << "\\quotes_times 1\n"; break;
421 case InsetQuotes::DoubleQ:
422 os << "\\quotes_times 2\n"; break;
424 os << "\\papercolumns " << columns
425 << "\n\\papersides " << sides
426 << "\n\\paperpagestyle " << pagestyle << '\n';
427 for (int i = 0; i < 4; ++i) {
428 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
429 if (user_defined_bullets[i].getFont() != -1) {
430 os << "\\bullet " << i
432 << user_defined_bullets[i].getFont()
434 << user_defined_bullets[i].getCharacter()
436 << user_defined_bullets[i].getSize()
437 << "\n\\end_bullet\n";
440 os << "\\bulletLaTeX " << i
442 << user_defined_bullets[i].getText()
443 << "\"\n\\end_bullet\n";
448 os << "\\tracking_changes " << tracking_changes << "\n";
450 if (tracking_changes) {
451 AuthorList::Authors::const_iterator it = authorlist.begin();
452 AuthorList::Authors::const_iterator end = authorlist.end();
453 for (; it != end; ++it) {
454 os << "\\author " << it->second << "\n";
460 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
461 TexRow & texrow) const
463 os << "\\documentclass";
465 LyXTextClass const & tclass = getLyXTextClass();
467 ostringstream clsoptions; // the document class options.
469 if (tokenPos(tclass.opt_fontsize(),
470 '|', fontsize) >= 0) {
471 // only write if existing in list (and not default)
472 clsoptions << fontsize << "pt,";
477 (paperpackage == PACKAGE_NONE)) {
480 clsoptions << "a3paper,";
483 clsoptions << "a4paper,";
486 clsoptions << "letterpaper,";
489 clsoptions << "a5paper,";
492 clsoptions << "b5paper,";
494 case PAPER_EXECUTIVEPAPER:
495 clsoptions << "executivepaper,";
497 case PAPER_LEGALPAPER:
498 clsoptions << "legalpaper,";
506 if (sides != tclass.sides()) {
508 case LyXTextClass::OneSide:
509 clsoptions << "oneside,";
511 case LyXTextClass::TwoSides:
512 clsoptions << "twoside,";
518 if (columns != tclass.columns()) {
520 clsoptions << "twocolumn,";
522 clsoptions << "onecolumn,";
526 && orientation == ORIENTATION_LANDSCAPE)
527 clsoptions << "landscape,";
529 // language should be a parameter to \documentclass
530 if (language->babel() == "hebrew"
531 && default_language->babel() != "hebrew")
532 // This seems necessary
533 features.useLanguage(default_language);
535 ostringstream language_options;
536 bool const use_babel = features.useBabel();
538 language_options << features.getLanguages();
539 language_options << language->babel();
540 if (lyxrc.language_global_options)
541 clsoptions << language_options.str() << ',';
544 // the user-defined options
545 if (!options.empty()) {
546 clsoptions << options << ',';
549 string strOptions(STRCONV(clsoptions.str()));
550 if (!strOptions.empty()) {
551 strOptions = rtrim(strOptions, ",");
552 os << '[' << strOptions << ']';
555 os << '{' << tclass.latexname() << "}\n";
557 // end of \documentclass defs
559 // font selection must be done before loading fontenc.sty
560 // The ae package is not needed when using OT1 font encoding.
561 if (fonts != "default" &&
562 (fonts != "ae" || lyxrc.fontenc != "default")) {
563 os << "\\usepackage{" << fonts << "}\n";
566 os << "\\usepackage{aecompl}\n";
570 // this one is not per buffer
571 if (lyxrc.fontenc != "default") {
572 os << "\\usepackage[" << lyxrc.fontenc
577 if (inputenc == "auto") {
578 string const doc_encoding =
579 language->encoding()->LatexName();
581 // Create a list with all the input encodings used
583 std::set<string> encodings =
584 features.getEncodingSet(doc_encoding);
586 os << "\\usepackage[";
587 std::copy(encodings.begin(), encodings.end(),
588 std::ostream_iterator<string>(os, ","));
589 os << doc_encoding << "]{inputenc}\n";
591 } else if (inputenc != "default") {
592 os << "\\usepackage[" << inputenc
597 // At the very beginning the text parameters.
598 if (paperpackage != PACKAGE_NONE) {
599 switch (paperpackage) {
603 os << "\\usepackage{a4}\n";
607 os << "\\usepackage{a4wide}\n";
610 case PACKAGE_WIDEMARGINSA4:
611 os << "\\usepackage[widemargins]{a4}\n";
617 os << "\\usepackage{geometry}\n";
619 os << "\\geometry{verbose";
620 if (orientation == ORIENTATION_LANDSCAPE)
622 switch (papersize2) {
623 case VM_PAPER_CUSTOM:
624 if (!paperwidth.empty())
627 if (!paperheight.empty())
628 os << ",paperheight="
631 case VM_PAPER_USLETTER:
632 os << ",letterpaper";
634 case VM_PAPER_USLEGAL:
637 case VM_PAPER_USEXECUTIVE:
638 os << ",executivepaper";
659 // default papersize ie VM_PAPER_DEFAULT
660 switch (lyxrc.default_papersize) {
661 case PAPER_DEFAULT: // keep compiler happy
663 os << ",letterpaper";
665 case PAPER_LEGALPAPER:
668 case PAPER_EXECUTIVEPAPER:
669 os << ",executivepaper";
685 if (!topmargin.empty())
686 os << ",tmargin=" << topmargin;
687 if (!bottommargin.empty())
688 os << ",bmargin=" << bottommargin;
689 if (!leftmargin.empty())
690 os << ",lmargin=" << leftmargin;
691 if (!rightmargin.empty())
692 os << ",rmargin=" << rightmargin;
693 if (!headheight.empty())
694 os << ",headheight=" << headheight;
695 if (!headsep.empty())
696 os << ",headsep=" << headsep;
697 if (!footskip.empty())
698 os << ",footskip=" << footskip;
703 if (tokenPos(tclass.opt_pagestyle(),
704 '|', pagestyle) >= 0) {
705 if (pagestyle == "fancy") {
706 os << "\\usepackage{fancyhdr}\n";
709 os << "\\pagestyle{" << pagestyle << "}\n";
713 if (secnumdepth != tclass.secnumdepth()) {
714 os << "\\setcounter{secnumdepth}{"
719 if (tocdepth != tclass.tocdepth()) {
720 os << "\\setcounter{tocdepth}{"
726 if (paragraph_separation) {
727 switch (defskip.kind()) {
728 case VSpace::SMALLSKIP:
729 os << "\\setlength\\parskip{\\smallskipamount}\n";
731 case VSpace::MEDSKIP:
732 os << "\\setlength\\parskip{\\medskipamount}\n";
734 case VSpace::BIGSKIP:
735 os << "\\setlength\\parskip{\\bigskipamount}\n";
738 os << "\\setlength\\parskip{"
739 << defskip.length().asLatexString()
742 default: // should never happen // Then delete it.
743 os << "\\setlength\\parskip{\\medskipamount}\n";
748 os << "\\setlength\\parindent{0pt}\n";
752 // Now insert the LyX specific LaTeX commands...
754 // The optional packages;
755 string lyxpreamble(features.getPackages());
757 // this might be useful...
758 lyxpreamble += "\n\\makeatletter\n";
760 // Some macros LyX will need
761 string tmppreamble(features.getMacros());
763 if (!tmppreamble.empty()) {
764 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
765 "LyX specific LaTeX commands.\n"
766 + tmppreamble + '\n';
769 // the text class specific preamble
770 tmppreamble = features.getTClassPreamble();
771 if (!tmppreamble.empty()) {
772 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
773 "Textclass specific LaTeX commands.\n"
774 + tmppreamble + '\n';
777 /* the user-defined preamble */
778 if (!preamble.empty()) {
779 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
780 "User specified LaTeX commands.\n"
784 // Itemize bullet settings need to be last in case the user
785 // defines their own bullets that use a package included
786 // in the user-defined preamble -- ARRae
787 // Actually it has to be done much later than that
788 // since some packages like frenchb make modifications
789 // at \begin{document} time -- JMarc
791 for (int i = 0; i < 4; ++i) {
792 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
793 if (bullets_def.empty())
794 bullets_def="\\AtBeginDocument{\n";
795 bullets_def += " \\renewcommand{\\labelitemi";
797 // `i' is one less than the item to modify
810 bullets_def += "}{" +
811 user_defined_bullets[i].getText()
816 if (!bullets_def.empty())
817 lyxpreamble += bullets_def + "}\n\n";
819 // We try to load babel late, in case it interferes
820 // with other packages.
822 string tmp = lyxrc.language_package;
823 if (!lyxrc.language_global_options
824 && tmp == "\\usepackage{babel}")
825 tmp = string("\\usepackage[") +
826 STRCONV(language_options.str()) +
828 lyxpreamble += tmp + "\n";
829 lyxpreamble += features.getBabelOptions();
832 lyxpreamble += "\\makeatother\n";
834 // dvipost settings come after everything else
835 if (tracking_changes) {
838 "\\dvipost{osstart color push Red}\n"
839 "\\dvipost{osend color pop}\n"
840 "\\dvipost{cbstart color push Blue}\n"
841 "\\dvipost{cbend color pop} \n";
845 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
846 for (int j = 0; j != nlines; ++j) {
854 void BufferParams::setPaperStuff()
856 papersize = PAPER_DEFAULT;
857 char const c1 = paperpackage;
858 if (c1 == PACKAGE_NONE) {
859 char const c2 = papersize2;
860 if (c2 == VM_PAPER_USLETTER)
861 papersize = PAPER_USLETTER;
862 else if (c2 == VM_PAPER_USLEGAL)
863 papersize = PAPER_LEGALPAPER;
864 else if (c2 == VM_PAPER_USEXECUTIVE)
865 papersize = PAPER_EXECUTIVEPAPER;
866 else if (c2 == VM_PAPER_A3)
867 papersize = PAPER_A3PAPER;
868 else if (c2 == VM_PAPER_A4)
869 papersize = PAPER_A4PAPER;
870 else if (c2 == VM_PAPER_A5)
871 papersize = PAPER_A5PAPER;
872 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
874 papersize = PAPER_B5PAPER;
875 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
876 (c1 == PACKAGE_WIDEMARGINSA4))
877 papersize = PAPER_A4PAPER;
881 void BufferParams::useClassDefaults()
883 LyXTextClass const & tclass = textclasslist[textclass];
885 sides = tclass.sides();
886 columns = tclass.columns();
887 pagestyle = tclass.pagestyle();
888 options = tclass.options();
889 secnumdepth = tclass.secnumdepth();
890 tocdepth = tclass.tocdepth();
894 bool BufferParams::hasClassDefaults() const
896 LyXTextClass const & tclass = textclasslist[textclass];
898 return (sides == tclass.sides()
899 && columns == tclass.columns()
900 && pagestyle == tclass.pagestyle()
901 && options == tclass.options()
902 && secnumdepth == tclass.secnumdepth()
903 && tocdepth == tclass.tocdepth());
907 LyXTextClass const & BufferParams::getLyXTextClass() const
909 return textclasslist[textclass];
913 void BufferParams::readPreamble(LyXLex & lex)
915 if (lex.getString() != "\\begin_preamble")
916 lyxerr << "Error (BufferParams::readPreamble):"
917 "consistency check failed." << endl;
919 preamble = lex.getLongString("\\end_preamble");
923 void BufferParams::readLanguage(LyXLex & lex)
925 if (!lex.next()) return;
927 string const tmptok = lex.getString();
929 // check if tmptok is part of tex_babel in tex-defs.h
930 language = languages.getLanguage(tmptok);
932 // Language tmptok was not found
933 language = default_language;
934 lyxerr << "Warning: Setting language `"
935 << tmptok << "' to `" << language->lang()
941 void BufferParams::readGraphicsDriver(LyXLex & lex)
943 if (!lex.next()) return;
945 string const tmptok = lex.getString();
946 // check if tmptok is part of tex_graphics in tex_defs.h
949 string const test = tex_graphics[n++];
951 if (test == tmptok) {
952 graphicsDriver = tmptok;
954 } else if (test == "last_item") {
956 "Warning: graphics driver `$$Token' not recognized!\n"
957 " Setting graphics driver to `default'.\n");
958 graphicsDriver = "default";
965 string const BufferParams::paperSizeName() const
967 char real_papersize = papersize;
968 if (real_papersize == PAPER_DEFAULT)
969 real_papersize = lyxrc.default_papersize;
971 switch (real_papersize) {
980 case PAPER_EXECUTIVEPAPER:
982 case PAPER_LEGALPAPER:
991 string const BufferParams::dvips_options() const
996 && papersize2 == VM_PAPER_CUSTOM
997 && !lyxrc.print_paper_dimension_flag.empty()
998 && !paperwidth.empty()
999 && !paperheight.empty()) {
1000 // using a custom papersize
1001 result = lyxrc.print_paper_dimension_flag;
1002 result += ' ' + paperwidth;
1003 result += ',' + paperheight;
1005 string const paper_option = paperSizeName();
1006 if (paper_option != "letter" ||
1007 orientation != ORIENTATION_LANDSCAPE) {
1008 // dvips won't accept -t letter -t landscape.
1009 // In all other cases, include the paper size
1011 result = lyxrc.print_paper_flag;
1012 result += ' ' + paper_option;
1015 if (orientation == ORIENTATION_LANDSCAPE &&
1016 papersize2 != VM_PAPER_CUSTOM)
1017 result += ' ' + lyxrc.print_landscape_flag;