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";
76 for (int iter = 0; iter < 4; ++iter) {
77 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
78 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
83 string const BufferParams::readToken(LyXLex & lex, string const & token)
85 if (token == "\\textclass") {
87 string const classname = lex.getString();
88 pair<bool, lyx::textclass_type> pp =
89 textclasslist.NumberOfClass(classname);
91 textclass = pp.second;
96 if (!getLyXTextClass().isTeXClassAvailable()) {
97 string msg = bformat(_("The document uses a missing "
98 "TeX class \"%1$s\".\n"), classname);
99 Alert::warning(_("Document class not available"),
100 msg + _("LyX will not be able to produce output."));
102 } else if (token == "\\begin_preamble") {
104 } else if (token == "\\options") {
106 options = lex.getString();
107 } else if (token == "\\language") {
109 } else if (token == "\\inputencoding") {
111 inputenc = lex.getString();
112 } else if (token == "\\graphics") {
113 readGraphicsDriver(lex);
114 } else if (token == "\\fontscheme") {
116 fonts = lex.getString();
117 } else if (token == "\\paragraph_separation") {
118 int tmpret = lex.findToken(string_paragraph_separation);
121 paragraph_separation =
122 static_cast<PARSEP>(tmpret);
123 } else if (token == "\\defskip") {
125 defskip = VSpace(lex.getString());
126 } else if (token == "\\quotes_language") {
127 // FIXME: should be params.readQuotes()
128 int tmpret = lex.findToken(string_quotes_language);
131 InsetQuotes::quote_language tmpl =
132 InsetQuotes::EnglishQ;
135 tmpl = InsetQuotes::EnglishQ;
138 tmpl = InsetQuotes::SwedishQ;
141 tmpl = InsetQuotes::GermanQ;
144 tmpl = InsetQuotes::PolishQ;
147 tmpl = InsetQuotes::FrenchQ;
150 tmpl = InsetQuotes::DanishQ;
153 quotes_language = tmpl;
154 } else if (token == "\\quotes_times") {
155 // FIXME: should be params.readQuotes()
157 switch (lex.getInteger()) {
159 quotes_times = InsetQuotes::SingleQ;
162 quotes_times = InsetQuotes::DoubleQ;
165 } else if (token == "\\papersize") {
166 int tmpret = lex.findToken(string_papersize);
170 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
171 } else if (token == "\\paperpackage") {
172 int tmpret = lex.findToken(string_paperpackages);
175 paperpackage = PACKAGE_NONE;
177 paperpackage = PAPER_PACKAGES(tmpret);
178 } else if (token == "\\use_geometry") {
180 use_geometry = lex.getInteger();
181 } else if (token == "\\use_amsmath") {
183 use_amsmath = static_cast<AMS>(
185 } else if (token == "\\use_natbib") {
187 use_natbib = lex.getInteger();
188 } else if (token == "\\use_numerical_citations") {
190 use_numerical_citations = lex.getInteger();
191 } else if (token == "\\tracking_changes") {
193 tracking_changes = lex.getInteger();
194 } else if (token == "\\author") {
196 istringstream ss(STRCONV(lex.getString()));
199 author_map.push_back(authorlist.record(a));
200 } else if (token == "\\paperorientation") {
201 int tmpret = lex.findToken(string_orientation);
205 static_cast<PAPER_ORIENTATION>(tmpret);
206 } else if (token == "\\paperwidth") {
208 paperwidth = lex.getString();
209 } else if (token == "\\paperheight") {
211 paperheight = lex.getString();
212 } else if (token == "\\leftmargin") {
214 leftmargin = lex.getString();
215 } else if (token == "\\topmargin") {
217 topmargin = lex.getString();
218 } else if (token == "\\rightmargin") {
220 rightmargin = lex.getString();
221 } else if (token == "\\bottommargin") {
223 bottommargin = lex.getString();
224 } else if (token == "\\headheight") {
226 headheight = lex.getString();
227 } else if (token == "\\headsep") {
229 headsep = lex.getString();
230 } else if (token == "\\footskip") {
232 footskip = lex.getString();
233 } else if (token == "\\paperfontsize") {
235 fontsize = rtrim(lex.getString());
236 } else if (token == "\\papercolumns") {
238 columns = lex.getInteger();
239 } else if (token == "\\papersides") {
241 switch (lex.getInteger()) {
243 case 1: sides = LyXTextClass::OneSide; break;
244 case 2: sides = LyXTextClass::TwoSides; break;
246 } else if (token == "\\paperpagestyle") {
248 pagestyle = rtrim(lex.getString());
249 } else if (token == "\\bullet") {
250 // FIXME: should be params.readBullets()
252 int const index = lex.getInteger();
254 int temp_int = lex.getInteger();
255 user_defined_bullets[index].setFont(temp_int);
256 temp_bullets[index].setFont(temp_int);
258 temp_int = lex.getInteger();
259 user_defined_bullets[index].setCharacter(temp_int);
260 temp_bullets[index].setCharacter(temp_int);
262 temp_int = lex.getInteger();
263 user_defined_bullets[index].setSize(temp_int);
264 temp_bullets[index].setSize(temp_int);
266 string const temp_str = lex.getString();
267 if (temp_str != "\\end_bullet") {
268 // this element isn't really necessary for
269 // parsing but is easier for humans
270 // to understand bullets. Put it back and
271 // set a debug message?
272 lex.printError("\\end_bullet expected, got" + temp_str);
273 //how can I put it back?
275 } else if (token == "\\bulletLaTeX") {
276 // The bullet class should be able to read this.
278 int const index = lex.getInteger();
280 string temp_str = lex.getString();
282 while (temp_str != "\\end_bullet") {
283 // this loop structure is needed when user
284 // enters an empty string since the first
285 // thing returned will be the \\end_bullet
287 // if the LaTeX entry has spaces. Each element
288 // therefore needs to be read in turn
291 temp_str = lex.getString();
294 user_defined_bullets[index].setText(sum_str);
295 temp_bullets[index].setText(sum_str);
296 } else if (token == "\\secnumdepth") {
298 secnumdepth = lex.getInteger();
299 } else if (token == "\\tocdepth") {
301 tocdepth = lex.getInteger();
302 } else if (token == "\\spacing") {
304 string const tmp = rtrim(lex.getString());
305 Spacing::Space tmp_space = Spacing::Default;
307 if (tmp == "single") {
308 tmp_space = Spacing::Single;
309 } else if (tmp == "onehalf") {
310 tmp_space = Spacing::Onehalf;
311 } else if (tmp == "double") {
312 tmp_space = Spacing::Double;
313 } else if (tmp == "other") {
315 tmp_space = Spacing::Other;
316 tmp_val = lex.getFloat();
318 lex.printError("Unknown spacing token: '$$Token'");
320 #if 0 // FIXME: Handled in lyx2lyx ?
321 // Small hack so that files written with klyx will be
324 par->params().spacing(Spacing(tmp_space, tmp_val));
326 spacing.set(tmp_space, tmp_val);
327 } else if (token == "\\float_placement") {
329 float_placement = lex.getString();
338 void BufferParams::writeFile(ostream & os) const
340 // The top of the file is written by the buffer.
341 // Prints out the buffer info into the .lyx file given by file
344 os << "\\textclass " << textclasslist[textclass].name() << '\n';
346 // then the the preamble
347 if (!preamble.empty()) {
348 // remove '\n' from the end of preamble
349 string const tmppreamble = rtrim(preamble, "\n");
350 os << "\\begin_preamble\n"
352 << "\n\\end_preamble\n";
356 if (!options.empty()) {
357 os << "\\options " << options << '\n';
360 /* then the text parameters */
361 if (language != ignore_language)
362 os << "\\language " << language->lang() << '\n';
363 os << "\\inputencoding " << inputenc
364 << "\n\\fontscheme " << fonts
365 << "\n\\graphics " << graphicsDriver << '\n';
367 if (!float_placement.empty()) {
368 os << "\\float_placement " << float_placement << '\n';
370 os << "\\paperfontsize " << fontsize << '\n';
372 spacing.writeFile(os);
374 os << "\\papersize " << string_papersize[papersize2]
375 << "\n\\paperpackage " << string_paperpackages[paperpackage]
376 << "\n\\use_geometry " << use_geometry
377 << "\n\\use_amsmath " << use_amsmath
378 << "\n\\use_natbib " << use_natbib
379 << "\n\\use_numerical_citations " << use_numerical_citations
380 << "\n\\paperorientation " << string_orientation[orientation]
382 if (!paperwidth.empty())
383 os << "\\paperwidth "
384 << VSpace(paperwidth).asLyXCommand() << '\n';
385 if (!paperheight.empty())
386 os << "\\paperheight "
387 << VSpace(paperheight).asLyXCommand() << '\n';
388 if (!leftmargin.empty())
389 os << "\\leftmargin "
390 << VSpace(leftmargin).asLyXCommand() << '\n';
391 if (!topmargin.empty())
393 << VSpace(topmargin).asLyXCommand() << '\n';
394 if (!rightmargin.empty())
395 os << "\\rightmargin "
396 << VSpace(rightmargin).asLyXCommand() << '\n';
397 if (!bottommargin.empty())
398 os << "\\bottommargin "
399 << VSpace(bottommargin).asLyXCommand() << '\n';
400 if (!headheight.empty())
401 os << "\\headheight "
402 << VSpace(headheight).asLyXCommand() << '\n';
403 if (!headsep.empty())
405 << VSpace(headsep).asLyXCommand() << '\n';
406 if (!footskip.empty())
408 << VSpace(footskip).asLyXCommand() << '\n';
409 os << "\\secnumdepth " << secnumdepth
410 << "\n\\tocdepth " << tocdepth
411 << "\n\\paragraph_separation "
412 << string_paragraph_separation[paragraph_separation]
413 << "\n\\defskip " << defskip.asLyXCommand()
414 << "\n\\quotes_language "
415 << string_quotes_language[quotes_language] << '\n';
416 switch (quotes_times) {
417 // An output operator for insetquotes would be nice
418 case InsetQuotes::SingleQ:
419 os << "\\quotes_times 1\n"; break;
420 case InsetQuotes::DoubleQ:
421 os << "\\quotes_times 2\n"; break;
423 os << "\\papercolumns " << columns
424 << "\n\\papersides " << sides
425 << "\n\\paperpagestyle " << pagestyle << '\n';
426 for (int i = 0; i < 4; ++i) {
427 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
428 if (user_defined_bullets[i].getFont() != -1) {
429 os << "\\bullet " << i
431 << user_defined_bullets[i].getFont()
433 << user_defined_bullets[i].getCharacter()
435 << user_defined_bullets[i].getSize()
436 << "\n\\end_bullet\n";
439 os << "\\bulletLaTeX " << i
441 << user_defined_bullets[i].getText()
442 << "\"\n\\end_bullet\n";
447 os << "\\tracking_changes " << tracking_changes << "\n";
449 if (tracking_changes) {
450 AuthorList::Authors::const_iterator it = authorlist.begin();
451 AuthorList::Authors::const_iterator end = authorlist.end();
452 for (; it != end; ++it) {
453 os << "\\author " << it->second << "\n";
459 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
460 TexRow & texrow) const
462 os << "\\documentclass";
464 LyXTextClass const & tclass = getLyXTextClass();
466 ostringstream clsoptions; // the document class options.
468 if (tokenPos(tclass.opt_fontsize(),
469 '|', fontsize) >= 0) {
470 // only write if existing in list (and not default)
471 clsoptions << fontsize << "pt,";
476 (paperpackage == PACKAGE_NONE)) {
479 clsoptions << "a3paper,";
482 clsoptions << "a4paper,";
485 clsoptions << "letterpaper,";
488 clsoptions << "a5paper,";
491 clsoptions << "b5paper,";
493 case PAPER_EXECUTIVEPAPER:
494 clsoptions << "executivepaper,";
496 case PAPER_LEGALPAPER:
497 clsoptions << "legalpaper,";
505 if (sides != tclass.sides()) {
507 case LyXTextClass::OneSide:
508 clsoptions << "oneside,";
510 case LyXTextClass::TwoSides:
511 clsoptions << "twoside,";
517 if (columns != tclass.columns()) {
519 clsoptions << "twocolumn,";
521 clsoptions << "onecolumn,";
525 && orientation == ORIENTATION_LANDSCAPE)
526 clsoptions << "landscape,";
528 // language should be a parameter to \documentclass
529 if (language->babel() == "hebrew"
530 && default_language->babel() != "hebrew")
531 // This seems necessary
532 features.useLanguage(default_language);
534 ostringstream language_options;
535 bool const use_babel = features.useBabel();
537 language_options << features.getLanguages();
538 language_options << language->babel();
539 if (lyxrc.language_global_options)
540 clsoptions << language_options.str() << ',';
543 // the user-defined options
544 if (!options.empty()) {
545 clsoptions << options << ',';
548 string strOptions(STRCONV(clsoptions.str()));
549 if (!strOptions.empty()) {
550 strOptions = rtrim(strOptions, ",");
551 os << '[' << strOptions << ']';
554 os << '{' << tclass.latexname() << "}\n";
556 // end of \documentclass defs
558 // font selection must be done before loading fontenc.sty
559 // The ae package is not needed when using OT1 font encoding.
560 if (fonts != "default" &&
561 (fonts != "ae" || lyxrc.fontenc != "default")) {
562 os << "\\usepackage{" << fonts << "}\n";
565 os << "\\usepackage{aecompl}\n";
569 // this one is not per buffer
570 if (lyxrc.fontenc != "default") {
571 os << "\\usepackage[" << lyxrc.fontenc
576 if (inputenc == "auto") {
577 string const doc_encoding =
578 language->encoding()->LatexName();
580 // Create a list with all the input encodings used
582 std::set<string> encodings =
583 features.getEncodingSet(doc_encoding);
585 os << "\\usepackage[";
586 std::copy(encodings.begin(), encodings.end(),
587 std::ostream_iterator<string>(os, ","));
588 os << doc_encoding << "]{inputenc}\n";
590 } else if (inputenc != "default") {
591 os << "\\usepackage[" << inputenc
596 // At the very beginning the text parameters.
597 if (paperpackage != PACKAGE_NONE) {
598 switch (paperpackage) {
602 os << "\\usepackage{a4}\n";
606 os << "\\usepackage{a4wide}\n";
609 case PACKAGE_WIDEMARGINSA4:
610 os << "\\usepackage[widemargins]{a4}\n";
616 os << "\\usepackage{geometry}\n";
618 os << "\\geometry{verbose";
619 if (orientation == ORIENTATION_LANDSCAPE)
621 switch (papersize2) {
622 case VM_PAPER_CUSTOM:
623 if (!paperwidth.empty())
626 if (!paperheight.empty())
627 os << ",paperheight="
630 case VM_PAPER_USLETTER:
631 os << ",letterpaper";
633 case VM_PAPER_USLEGAL:
636 case VM_PAPER_USEXECUTIVE:
637 os << ",executivepaper";
658 // default papersize ie VM_PAPER_DEFAULT
659 switch (lyxrc.default_papersize) {
660 case PAPER_DEFAULT: // keep compiler happy
662 os << ",letterpaper";
664 case PAPER_LEGALPAPER:
667 case PAPER_EXECUTIVEPAPER:
668 os << ",executivepaper";
684 if (!topmargin.empty())
685 os << ",tmargin=" << topmargin;
686 if (!bottommargin.empty())
687 os << ",bmargin=" << bottommargin;
688 if (!leftmargin.empty())
689 os << ",lmargin=" << leftmargin;
690 if (!rightmargin.empty())
691 os << ",rmargin=" << rightmargin;
692 if (!headheight.empty())
693 os << ",headheight=" << headheight;
694 if (!headsep.empty())
695 os << ",headsep=" << headsep;
696 if (!footskip.empty())
697 os << ",footskip=" << footskip;
702 if (tokenPos(tclass.opt_pagestyle(),
703 '|', pagestyle) >= 0) {
704 if (pagestyle == "fancy") {
705 os << "\\usepackage{fancyhdr}\n";
708 os << "\\pagestyle{" << pagestyle << "}\n";
712 if (secnumdepth != tclass.secnumdepth()) {
713 os << "\\setcounter{secnumdepth}{"
718 if (tocdepth != tclass.tocdepth()) {
719 os << "\\setcounter{tocdepth}{"
725 if (paragraph_separation) {
726 switch (defskip.kind()) {
727 case VSpace::SMALLSKIP:
728 os << "\\setlength\\parskip{\\smallskipamount}\n";
730 case VSpace::MEDSKIP:
731 os << "\\setlength\\parskip{\\medskipamount}\n";
733 case VSpace::BIGSKIP:
734 os << "\\setlength\\parskip{\\bigskipamount}\n";
737 os << "\\setlength\\parskip{"
738 << defskip.length().asLatexString()
741 default: // should never happen // Then delete it.
742 os << "\\setlength\\parskip{\\medskipamount}\n";
747 os << "\\setlength\\parindent{0pt}\n";
751 // Now insert the LyX specific LaTeX commands...
753 // The optional packages;
754 string lyxpreamble(features.getPackages());
756 // this might be useful...
757 lyxpreamble += "\n\\makeatletter\n";
759 // Some macros LyX will need
760 string tmppreamble(features.getMacros());
762 if (!tmppreamble.empty()) {
763 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
764 "LyX specific LaTeX commands.\n"
765 + tmppreamble + '\n';
768 // the text class specific preamble
769 tmppreamble = features.getTClassPreamble();
770 if (!tmppreamble.empty()) {
771 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
772 "Textclass specific LaTeX commands.\n"
773 + tmppreamble + '\n';
776 /* the user-defined preamble */
777 if (!preamble.empty()) {
778 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
779 "User specified LaTeX commands.\n"
783 // Itemize bullet settings need to be last in case the user
784 // defines their own bullets that use a package included
785 // in the user-defined preamble -- ARRae
786 // Actually it has to be done much later than that
787 // since some packages like frenchb make modifications
788 // at \begin{document} time -- JMarc
790 for (int i = 0; i < 4; ++i) {
791 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
792 if (bullets_def.empty())
793 bullets_def="\\AtBeginDocument{\n";
794 bullets_def += " \\renewcommand{\\labelitemi";
796 // `i' is one less than the item to modify
809 bullets_def += "}{" +
810 user_defined_bullets[i].getText()
815 if (!bullets_def.empty())
816 lyxpreamble += bullets_def + "}\n\n";
818 // We try to load babel late, in case it interferes
819 // with other packages.
821 string tmp = lyxrc.language_package;
822 if (!lyxrc.language_global_options
823 && tmp == "\\usepackage{babel}")
824 tmp = string("\\usepackage[") +
825 STRCONV(language_options.str()) +
827 lyxpreamble += tmp + "\n";
828 lyxpreamble += features.getBabelOptions();
831 lyxpreamble += "\\makeatother\n";
833 // dvipost settings come after everything else
834 if (tracking_changes) {
837 "\\dvipost{osstart color push Red}\n"
838 "\\dvipost{osend color pop}\n"
839 "\\dvipost{cbstart color push Blue}\n"
840 "\\dvipost{cbend color pop} \n";
844 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
845 for (int j = 0; j != nlines; ++j) {
853 void BufferParams::setPaperStuff()
855 papersize = PAPER_DEFAULT;
856 char const c1 = paperpackage;
857 if (c1 == PACKAGE_NONE) {
858 char const c2 = papersize2;
859 if (c2 == VM_PAPER_USLETTER)
860 papersize = PAPER_USLETTER;
861 else if (c2 == VM_PAPER_USLEGAL)
862 papersize = PAPER_LEGALPAPER;
863 else if (c2 == VM_PAPER_USEXECUTIVE)
864 papersize = PAPER_EXECUTIVEPAPER;
865 else if (c2 == VM_PAPER_A3)
866 papersize = PAPER_A3PAPER;
867 else if (c2 == VM_PAPER_A4)
868 papersize = PAPER_A4PAPER;
869 else if (c2 == VM_PAPER_A5)
870 papersize = PAPER_A5PAPER;
871 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
873 papersize = PAPER_B5PAPER;
874 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
875 (c1 == PACKAGE_WIDEMARGINSA4))
876 papersize = PAPER_A4PAPER;
880 void BufferParams::useClassDefaults()
882 LyXTextClass const & tclass = textclasslist[textclass];
884 sides = tclass.sides();
885 columns = tclass.columns();
886 pagestyle = tclass.pagestyle();
887 options = tclass.options();
888 secnumdepth = tclass.secnumdepth();
889 tocdepth = tclass.tocdepth();
893 bool BufferParams::hasClassDefaults() const
895 LyXTextClass const & tclass = textclasslist[textclass];
897 return (sides == tclass.sides()
898 && columns == tclass.columns()
899 && pagestyle == tclass.pagestyle()
900 && options == tclass.options()
901 && secnumdepth == tclass.secnumdepth()
902 && tocdepth == tclass.tocdepth());
906 LyXTextClass const & BufferParams::getLyXTextClass() const
908 return textclasslist[textclass];
912 void BufferParams::readPreamble(LyXLex & lex)
914 if (lex.getString() != "\\begin_preamble")
915 lyxerr << "Error (BufferParams::readPreamble):"
916 "consistency check failed." << endl;
918 preamble = lex.getLongString("\\end_preamble");
922 void BufferParams::readLanguage(LyXLex & lex)
924 if (!lex.next()) return;
926 string const tmptok = lex.getString();
928 // check if tmptok is part of tex_babel in tex-defs.h
929 language = languages.getLanguage(tmptok);
931 // Language tmptok was not found
932 language = default_language;
933 lyxerr << "Warning: Setting language `"
934 << tmptok << "' to `" << language->lang()
940 void BufferParams::readGraphicsDriver(LyXLex & lex)
942 if (!lex.next()) return;
944 string const tmptok = lex.getString();
945 // check if tmptok is part of tex_graphics in tex_defs.h
948 string const test = tex_graphics[n++];
950 if (test == tmptok) {
951 graphicsDriver = tmptok;
953 } else if (test == "last_item") {
955 "Warning: graphics driver `$$Token' not recognized!\n"
956 " Setting graphics driver to `default'.\n");
957 graphicsDriver = "default";
964 string const BufferParams::paperSizeName() const
966 char real_papersize = papersize;
967 if (real_papersize == PAPER_DEFAULT)
968 real_papersize = lyxrc.default_papersize;
970 switch (real_papersize) {
979 case PAPER_EXECUTIVEPAPER:
981 case PAPER_LEGALPAPER:
990 string const BufferParams::dvips_options() const
995 && papersize2 == VM_PAPER_CUSTOM
996 && !lyxrc.print_paper_dimension_flag.empty()
997 && !paperwidth.empty()
998 && !paperheight.empty()) {
999 // using a custom papersize
1000 result = lyxrc.print_paper_dimension_flag;
1001 result += ' ' + paperwidth;
1002 result += ',' + paperheight;
1004 string const paper_option = paperSizeName();
1005 if (paper_option != "letter" ||
1006 orientation != ORIENTATION_LANDSCAPE) {
1007 // dvips won't accept -t letter -t landscape.
1008 // In all other cases, include the paper size
1010 result = lyxrc.print_paper_flag;
1011 result += ' ' + paper_option;
1014 if (orientation == ORIENTATION_LANDSCAPE &&
1015 papersize2 != VM_PAPER_CUSTOM)
1016 result += ' ' + lyxrc.print_landscape_flag;