3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alfredo Braunstein
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author André Pönitz
11 * \author Martin Vermeer
13 * Full author contact details are available in file CREDITS.
18 #include "bufferparams.h"
25 #include "LaTeXFeatures.h"
26 #include "latexrunparams.h"
29 #include "lyxtextclasslist.h"
30 #include "tex-strings.h"
33 #include "frontends/Alert.h"
35 #include "support/lyxalgo.h" // for lyx::count
37 #include "support/std_sstream.h"
39 using namespace lyx::support;
43 using std::istringstream;
45 using std::ostringstream;
49 BufferParams::BufferParams()
50 // Initialize textclass to point to article. if `first' is
51 // true in the returned pair, then `second' is the textclass
52 // number; if it is false, second is 0. In both cases, second
54 : textclass(textclasslist.NumberOfClass("article").second)
56 paragraph_separation = PARSEP_INDENT;
57 defskip = VSpace(VSpace::MEDSKIP);
58 quotes_language = InsetQuotes::EnglishQ;
59 quotes_times = InsetQuotes::DoubleQ;
63 papersize = PAPER_DEFAULT;
64 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
65 paperpackage = PACKAGE_NONE;
66 orientation = ORIENTATION_PORTRAIT;
68 use_amsmath = AMS_AUTO;
70 use_numerical_citations = false;
71 tracking_changes = false;
74 language = default_language;
77 graphicsDriver = "default";
78 sides = LyXTextClass::OneSide;
80 pagestyle = "default";
82 for (int iter = 0; iter < 4; ++iter) {
83 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
84 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
89 string const BufferParams::readToken(LyXLex & lex, string const & token)
91 if (token == "\\textclass") {
93 string const classname = lex.getString();
94 pair<bool, lyx::textclass_type> pp =
95 textclasslist.NumberOfClass(classname);
97 textclass = pp.second;
102 if (!getLyXTextClass().isTeXClassAvailable()) {
103 string msg = bformat(_("The document uses a missing "
104 "TeX class \"%1$s\".\n"), classname);
105 Alert::warning(_("Document class not available"),
106 msg + _("LyX will not be able to produce output."));
108 } else if (token == "\\begin_preamble") {
110 } else if (token == "\\options") {
112 options = lex.getString();
113 } else if (token == "\\language") {
115 } else if (token == "\\inputencoding") {
117 inputenc = lex.getString();
118 } else if (token == "\\graphics") {
119 readGraphicsDriver(lex);
120 } else if (token == "\\fontscheme") {
122 fonts = lex.getString();
123 } else if (token == "\\paragraph_separation") {
124 int tmpret = lex.findToken(string_paragraph_separation);
127 paragraph_separation =
128 static_cast<PARSEP>(tmpret);
129 } else if (token == "\\defskip") {
131 defskip = VSpace(lex.getString());
132 } else if (token == "\\quotes_language") {
133 // FIXME: should be params.readQuotes()
134 int tmpret = lex.findToken(string_quotes_language);
137 InsetQuotes::quote_language tmpl =
138 InsetQuotes::EnglishQ;
141 tmpl = InsetQuotes::EnglishQ;
144 tmpl = InsetQuotes::SwedishQ;
147 tmpl = InsetQuotes::GermanQ;
150 tmpl = InsetQuotes::PolishQ;
153 tmpl = InsetQuotes::FrenchQ;
156 tmpl = InsetQuotes::DanishQ;
159 quotes_language = tmpl;
160 } else if (token == "\\quotes_times") {
161 // FIXME: should be params.readQuotes()
163 switch (lex.getInteger()) {
165 quotes_times = InsetQuotes::SingleQ;
168 quotes_times = InsetQuotes::DoubleQ;
171 } else if (token == "\\papersize") {
172 int tmpret = lex.findToken(string_papersize);
176 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
177 } else if (token == "\\paperpackage") {
178 int tmpret = lex.findToken(string_paperpackages);
181 paperpackage = PACKAGE_NONE;
183 paperpackage = PAPER_PACKAGES(tmpret);
184 } else if (token == "\\use_geometry") {
186 use_geometry = lex.getInteger();
187 } else if (token == "\\use_amsmath") {
189 use_amsmath = static_cast<AMS>(
191 } else if (token == "\\use_natbib") {
193 use_natbib = lex.getInteger();
194 } else if (token == "\\use_numerical_citations") {
196 use_numerical_citations = lex.getInteger();
197 } else if (token == "\\tracking_changes") {
199 tracking_changes = lex.getInteger();
200 } else if (token == "\\branch") {
202 string branch = lex.getString();
203 branchlist.add(branch);
206 string const tok = lex.getString();
207 if (tok == "\\end_branch")
209 if (tok == "\\selected") {
211 branchlist.setSelected(branch, lex.getInteger());
213 // not yet operational
214 if (tok == "\\color") {
216 string color = lex.getString();
217 branchlist.setColor(branch, color);
218 // Update also the LColor table:
220 color = lcolor.getX11Name(LColor::background);
221 lcolor.fill(static_cast<LColor::color>(lcolor.size()),
225 } else if (token == "\\author") {
227 istringstream ss(STRCONV(lex.getString()));
230 author_map.push_back(authorlist.record(a));
231 } else if (token == "\\paperorientation") {
232 int tmpret = lex.findToken(string_orientation);
236 static_cast<PAPER_ORIENTATION>(tmpret);
237 } else if (token == "\\paperwidth") {
239 paperwidth = lex.getString();
240 } else if (token == "\\paperheight") {
242 paperheight = lex.getString();
243 } else if (token == "\\leftmargin") {
245 leftmargin = lex.getString();
246 } else if (token == "\\topmargin") {
248 topmargin = lex.getString();
249 } else if (token == "\\rightmargin") {
251 rightmargin = lex.getString();
252 } else if (token == "\\bottommargin") {
254 bottommargin = lex.getString();
255 } else if (token == "\\headheight") {
257 headheight = lex.getString();
258 } else if (token == "\\headsep") {
260 headsep = lex.getString();
261 } else if (token == "\\footskip") {
263 footskip = lex.getString();
264 } else if (token == "\\paperfontsize") {
266 fontsize = rtrim(lex.getString());
267 } else if (token == "\\papercolumns") {
269 columns = lex.getInteger();
270 } else if (token == "\\papersides") {
272 switch (lex.getInteger()) {
274 case 1: sides = LyXTextClass::OneSide; break;
275 case 2: sides = LyXTextClass::TwoSides; break;
277 } else if (token == "\\paperpagestyle") {
279 pagestyle = rtrim(lex.getString());
280 } else if (token == "\\bullet") {
281 // FIXME: should be params.readBullets()
283 int const index = lex.getInteger();
285 int temp_int = lex.getInteger();
286 user_defined_bullets[index].setFont(temp_int);
287 temp_bullets[index].setFont(temp_int);
289 temp_int = lex.getInteger();
290 user_defined_bullets[index].setCharacter(temp_int);
291 temp_bullets[index].setCharacter(temp_int);
293 temp_int = lex.getInteger();
294 user_defined_bullets[index].setSize(temp_int);
295 temp_bullets[index].setSize(temp_int);
297 string const temp_str = lex.getString();
298 if (temp_str != "\\end_bullet") {
299 // this element isn't really necessary for
300 // parsing but is easier for humans
301 // to understand bullets. Put it back and
302 // set a debug message?
303 lex.printError("\\end_bullet expected, got" + temp_str);
304 //how can I put it back?
306 } else if (token == "\\bulletLaTeX") {
307 // The bullet class should be able to read this.
309 int const index = lex.getInteger();
311 string temp_str = lex.getString();
313 while (temp_str != "\\end_bullet") {
314 // this loop structure is needed when user
315 // enters an empty string since the first
316 // thing returned will be the \\end_bullet
318 // if the LaTeX entry has spaces. Each element
319 // therefore needs to be read in turn
322 temp_str = lex.getString();
325 user_defined_bullets[index].setText(sum_str);
326 temp_bullets[index].setText(sum_str);
327 } else if (token == "\\secnumdepth") {
329 secnumdepth = lex.getInteger();
330 } else if (token == "\\tocdepth") {
332 tocdepth = lex.getInteger();
333 } else if (token == "\\spacing") {
335 string const tmp = rtrim(lex.getString());
336 Spacing::Space tmp_space = Spacing::Default;
338 if (tmp == "single") {
339 tmp_space = Spacing::Single;
340 } else if (tmp == "onehalf") {
341 tmp_space = Spacing::Onehalf;
342 } else if (tmp == "double") {
343 tmp_space = Spacing::Double;
344 } else if (tmp == "other") {
346 tmp_space = Spacing::Other;
347 tmp_val = lex.getFloat();
349 lex.printError("Unknown spacing token: '$$Token'");
351 #if 0 // FIXME: Handled in lyx2lyx ?
352 // Small hack so that files written with klyx will be
355 par->params().spacing(Spacing(tmp_space, tmp_val));
357 spacing.set(tmp_space, tmp_val);
358 } else if (token == "\\float_placement") {
360 float_placement = lex.getString();
369 void BufferParams::writeFile(ostream & os) const
371 // The top of the file is written by the buffer.
372 // Prints out the buffer info into the .lyx file given by file
375 os << "\\textclass " << textclasslist[textclass].name() << '\n';
377 // then the the preamble
378 if (!preamble.empty()) {
379 // remove '\n' from the end of preamble
380 string const tmppreamble = rtrim(preamble, "\n");
381 os << "\\begin_preamble\n"
383 << "\n\\end_preamble\n";
387 if (!options.empty()) {
388 os << "\\options " << options << '\n';
391 /* then the text parameters */
392 if (language != ignore_language)
393 os << "\\language " << language->lang() << '\n';
394 os << "\\inputencoding " << inputenc
395 << "\n\\fontscheme " << fonts
396 << "\n\\graphics " << graphicsDriver << '\n';
398 if (!float_placement.empty()) {
399 os << "\\float_placement " << float_placement << '\n';
401 os << "\\paperfontsize " << fontsize << '\n';
403 spacing.writeFile(os);
405 os << "\\papersize " << string_papersize[papersize2]
406 << "\n\\paperpackage " << string_paperpackages[paperpackage]
407 << "\n\\use_geometry " << use_geometry
408 << "\n\\use_amsmath " << use_amsmath
409 << "\n\\use_natbib " << use_natbib
410 << "\n\\use_numerical_citations " << use_numerical_citations
411 << "\n\\paperorientation " << string_orientation[orientation]
414 std::list<Branch>::const_iterator it = branchlist.begin();
415 std::list<Branch>::const_iterator end = branchlist.end();
416 for (; it != end; ++it) {
417 os << "\\branch " << it->getBranch()
418 << "\n\\selected " << it->getSelected()
419 << "\n\\color " << it->getColor()
424 if (!paperwidth.empty())
425 os << "\\paperwidth "
426 << VSpace(paperwidth).asLyXCommand() << '\n';
427 if (!paperheight.empty())
428 os << "\\paperheight "
429 << VSpace(paperheight).asLyXCommand() << '\n';
430 if (!leftmargin.empty())
431 os << "\\leftmargin "
432 << VSpace(leftmargin).asLyXCommand() << '\n';
433 if (!topmargin.empty())
435 << VSpace(topmargin).asLyXCommand() << '\n';
436 if (!rightmargin.empty())
437 os << "\\rightmargin "
438 << VSpace(rightmargin).asLyXCommand() << '\n';
439 if (!bottommargin.empty())
440 os << "\\bottommargin "
441 << VSpace(bottommargin).asLyXCommand() << '\n';
442 if (!headheight.empty())
443 os << "\\headheight "
444 << VSpace(headheight).asLyXCommand() << '\n';
445 if (!headsep.empty())
447 << VSpace(headsep).asLyXCommand() << '\n';
448 if (!footskip.empty())
450 << VSpace(footskip).asLyXCommand() << '\n';
451 os << "\\secnumdepth " << secnumdepth
452 << "\n\\tocdepth " << tocdepth
453 << "\n\\paragraph_separation "
454 << string_paragraph_separation[paragraph_separation]
455 << "\n\\defskip " << defskip.asLyXCommand()
456 << "\n\\quotes_language "
457 << string_quotes_language[quotes_language] << '\n';
458 switch (quotes_times) {
459 // An output operator for insetquotes would be nice
460 case InsetQuotes::SingleQ:
461 os << "\\quotes_times 1\n"; break;
462 case InsetQuotes::DoubleQ:
463 os << "\\quotes_times 2\n"; break;
465 os << "\\papercolumns " << columns
466 << "\n\\papersides " << sides
467 << "\n\\paperpagestyle " << pagestyle << '\n';
468 for (int i = 0; i < 4; ++i) {
469 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
470 if (user_defined_bullets[i].getFont() != -1) {
471 os << "\\bullet " << i
473 << user_defined_bullets[i].getFont()
475 << user_defined_bullets[i].getCharacter()
477 << user_defined_bullets[i].getSize()
478 << "\n\\end_bullet\n";
481 os << "\\bulletLaTeX " << i
483 << user_defined_bullets[i].getText()
484 << "\"\n\\end_bullet\n";
489 os << "\\tracking_changes " << tracking_changes << "\n";
491 if (tracking_changes) {
492 AuthorList::Authors::const_iterator it = authorlist.begin();
493 AuthorList::Authors::const_iterator end = authorlist.end();
494 for (; it != end; ++it) {
495 os << "\\author " << it->second << "\n";
501 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
502 TexRow & texrow) const
504 os << "\\documentclass";
506 LyXTextClass const & tclass = getLyXTextClass();
508 ostringstream clsoptions; // the document class options.
510 if (tokenPos(tclass.opt_fontsize(),
511 '|', fontsize) >= 0) {
512 // only write if existing in list (and not default)
513 clsoptions << fontsize << "pt,";
518 (paperpackage == PACKAGE_NONE)) {
521 clsoptions << "a3paper,";
524 clsoptions << "a4paper,";
527 clsoptions << "letterpaper,";
530 clsoptions << "a5paper,";
533 clsoptions << "b5paper,";
535 case PAPER_EXECUTIVEPAPER:
536 clsoptions << "executivepaper,";
538 case PAPER_LEGALPAPER:
539 clsoptions << "legalpaper,";
547 if (sides != tclass.sides()) {
549 case LyXTextClass::OneSide:
550 clsoptions << "oneside,";
552 case LyXTextClass::TwoSides:
553 clsoptions << "twoside,";
559 if (columns != tclass.columns()) {
561 clsoptions << "twocolumn,";
563 clsoptions << "onecolumn,";
567 && orientation == ORIENTATION_LANDSCAPE)
568 clsoptions << "landscape,";
570 // language should be a parameter to \documentclass
571 if (language->babel() == "hebrew"
572 && default_language->babel() != "hebrew")
573 // This seems necessary
574 features.useLanguage(default_language);
576 ostringstream language_options;
577 bool const use_babel = features.useBabel();
579 language_options << features.getLanguages();
580 language_options << language->babel();
581 if (lyxrc.language_global_options)
582 clsoptions << language_options.str() << ',';
585 // the user-defined options
586 if (!options.empty()) {
587 clsoptions << options << ',';
590 string strOptions(STRCONV(clsoptions.str()));
591 if (!strOptions.empty()) {
592 strOptions = rtrim(strOptions, ",");
593 os << '[' << strOptions << ']';
596 os << '{' << tclass.latexname() << "}\n";
598 // end of \documentclass defs
600 // font selection must be done before loading fontenc.sty
601 // The ae package is not needed when using OT1 font encoding.
602 if (fonts != "default" &&
603 (fonts != "ae" || lyxrc.fontenc != "default")) {
604 os << "\\usepackage{" << fonts << "}\n";
607 os << "\\usepackage{aecompl}\n";
611 // this one is not per buffer
612 if (lyxrc.fontenc != "default") {
613 os << "\\usepackage[" << lyxrc.fontenc
618 if (inputenc == "auto") {
619 string const doc_encoding =
620 language->encoding()->LatexName();
622 // Create a list with all the input encodings used
624 std::set<string> encodings =
625 features.getEncodingSet(doc_encoding);
627 os << "\\usepackage[";
628 std::copy(encodings.begin(), encodings.end(),
629 std::ostream_iterator<string>(os, ","));
630 os << doc_encoding << "]{inputenc}\n";
632 } else if (inputenc != "default") {
633 os << "\\usepackage[" << inputenc
638 // At the very beginning the text parameters.
639 if (paperpackage != PACKAGE_NONE) {
640 switch (paperpackage) {
644 os << "\\usepackage{a4}\n";
648 os << "\\usepackage{a4wide}\n";
651 case PACKAGE_WIDEMARGINSA4:
652 os << "\\usepackage[widemargins]{a4}\n";
658 os << "\\usepackage{geometry}\n";
660 os << "\\geometry{verbose";
661 if (orientation == ORIENTATION_LANDSCAPE)
663 switch (papersize2) {
664 case VM_PAPER_CUSTOM:
665 if (!paperwidth.empty())
668 if (!paperheight.empty())
669 os << ",paperheight="
672 case VM_PAPER_USLETTER:
673 os << ",letterpaper";
675 case VM_PAPER_USLEGAL:
678 case VM_PAPER_USEXECUTIVE:
679 os << ",executivepaper";
700 // default papersize ie VM_PAPER_DEFAULT
701 switch (lyxrc.default_papersize) {
702 case PAPER_DEFAULT: // keep compiler happy
704 os << ",letterpaper";
706 case PAPER_LEGALPAPER:
709 case PAPER_EXECUTIVEPAPER:
710 os << ",executivepaper";
726 if (!topmargin.empty())
727 os << ",tmargin=" << topmargin;
728 if (!bottommargin.empty())
729 os << ",bmargin=" << bottommargin;
730 if (!leftmargin.empty())
731 os << ",lmargin=" << leftmargin;
732 if (!rightmargin.empty())
733 os << ",rmargin=" << rightmargin;
734 if (!headheight.empty())
735 os << ",headheight=" << headheight;
736 if (!headsep.empty())
737 os << ",headsep=" << headsep;
738 if (!footskip.empty())
739 os << ",footskip=" << footskip;
744 if (tokenPos(tclass.opt_pagestyle(),
745 '|', pagestyle) >= 0) {
746 if (pagestyle == "fancy") {
747 os << "\\usepackage{fancyhdr}\n";
750 os << "\\pagestyle{" << pagestyle << "}\n";
754 if (secnumdepth != tclass.secnumdepth()) {
755 os << "\\setcounter{secnumdepth}{"
760 if (tocdepth != tclass.tocdepth()) {
761 os << "\\setcounter{tocdepth}{"
767 if (paragraph_separation) {
768 switch (defskip.kind()) {
769 case VSpace::SMALLSKIP:
770 os << "\\setlength\\parskip{\\smallskipamount}\n";
772 case VSpace::MEDSKIP:
773 os << "\\setlength\\parskip{\\medskipamount}\n";
775 case VSpace::BIGSKIP:
776 os << "\\setlength\\parskip{\\bigskipamount}\n";
779 os << "\\setlength\\parskip{"
780 << defskip.length().asLatexString()
783 default: // should never happen // Then delete it.
784 os << "\\setlength\\parskip{\\medskipamount}\n";
789 os << "\\setlength\\parindent{0pt}\n";
793 // Now insert the LyX specific LaTeX commands...
795 // The optional packages;
796 string lyxpreamble(features.getPackages());
798 // this might be useful...
799 lyxpreamble += "\n\\makeatletter\n";
801 // Some macros LyX will need
802 string tmppreamble(features.getMacros());
804 if (!tmppreamble.empty()) {
805 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
806 "LyX specific LaTeX commands.\n"
807 + tmppreamble + '\n';
810 // the text class specific preamble
811 tmppreamble = features.getTClassPreamble();
812 if (!tmppreamble.empty()) {
813 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
814 "Textclass specific LaTeX commands.\n"
815 + tmppreamble + '\n';
818 /* the user-defined preamble */
819 if (!preamble.empty()) {
820 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
821 "User specified LaTeX commands.\n"
825 // Itemize bullet settings need to be last in case the user
826 // defines their own bullets that use a package included
827 // in the user-defined preamble -- ARRae
828 // Actually it has to be done much later than that
829 // since some packages like frenchb make modifications
830 // at \begin{document} time -- JMarc
832 for (int i = 0; i < 4; ++i) {
833 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
834 if (bullets_def.empty())
835 bullets_def="\\AtBeginDocument{\n";
836 bullets_def += " \\renewcommand{\\labelitemi";
838 // `i' is one less than the item to modify
851 bullets_def += "}{" +
852 user_defined_bullets[i].getText()
857 if (!bullets_def.empty())
858 lyxpreamble += bullets_def + "}\n\n";
860 // We try to load babel late, in case it interferes
861 // with other packages.
863 string tmp = lyxrc.language_package;
864 if (!lyxrc.language_global_options
865 && tmp == "\\usepackage{babel}")
866 tmp = string("\\usepackage[") +
867 STRCONV(language_options.str()) +
869 lyxpreamble += tmp + "\n";
870 lyxpreamble += features.getBabelOptions();
873 lyxpreamble += "\\makeatother\n";
875 // dvipost settings come after everything else
876 if (tracking_changes) {
879 "\\dvipost{osstart color push Red}\n"
880 "\\dvipost{osend color pop}\n"
881 "\\dvipost{cbstart color push Blue}\n"
882 "\\dvipost{cbend color pop} \n";
886 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
887 for (int j = 0; j != nlines; ++j) {
895 void BufferParams::setPaperStuff()
897 papersize = PAPER_DEFAULT;
898 char const c1 = paperpackage;
899 if (c1 == PACKAGE_NONE) {
900 char const c2 = papersize2;
901 if (c2 == VM_PAPER_USLETTER)
902 papersize = PAPER_USLETTER;
903 else if (c2 == VM_PAPER_USLEGAL)
904 papersize = PAPER_LEGALPAPER;
905 else if (c2 == VM_PAPER_USEXECUTIVE)
906 papersize = PAPER_EXECUTIVEPAPER;
907 else if (c2 == VM_PAPER_A3)
908 papersize = PAPER_A3PAPER;
909 else if (c2 == VM_PAPER_A4)
910 papersize = PAPER_A4PAPER;
911 else if (c2 == VM_PAPER_A5)
912 papersize = PAPER_A5PAPER;
913 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
915 papersize = PAPER_B5PAPER;
916 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
917 (c1 == PACKAGE_WIDEMARGINSA4))
918 papersize = PAPER_A4PAPER;
922 void BufferParams::useClassDefaults()
924 LyXTextClass const & tclass = textclasslist[textclass];
926 sides = tclass.sides();
927 columns = tclass.columns();
928 pagestyle = tclass.pagestyle();
929 options = tclass.options();
930 secnumdepth = tclass.secnumdepth();
931 tocdepth = tclass.tocdepth();
935 bool BufferParams::hasClassDefaults() const
937 LyXTextClass const & tclass = textclasslist[textclass];
939 return (sides == tclass.sides()
940 && columns == tclass.columns()
941 && pagestyle == tclass.pagestyle()
942 && options == tclass.options()
943 && secnumdepth == tclass.secnumdepth()
944 && tocdepth == tclass.tocdepth());
948 LyXTextClass const & BufferParams::getLyXTextClass() const
950 return textclasslist[textclass];
954 void BufferParams::readPreamble(LyXLex & lex)
956 if (lex.getString() != "\\begin_preamble")
957 lyxerr << "Error (BufferParams::readPreamble):"
958 "consistency check failed." << endl;
960 preamble = lex.getLongString("\\end_preamble");
964 void BufferParams::readLanguage(LyXLex & lex)
966 if (!lex.next()) return;
968 string const tmptok = lex.getString();
970 // check if tmptok is part of tex_babel in tex-defs.h
971 language = languages.getLanguage(tmptok);
973 // Language tmptok was not found
974 language = default_language;
975 lyxerr << "Warning: Setting language `"
976 << tmptok << "' to `" << language->lang()
982 void BufferParams::readGraphicsDriver(LyXLex & lex)
984 if (!lex.next()) return;
986 string const tmptok = lex.getString();
987 // check if tmptok is part of tex_graphics in tex_defs.h
990 string const test = tex_graphics[n++];
992 if (test == tmptok) {
993 graphicsDriver = tmptok;
995 } else if (test == "last_item") {
997 "Warning: graphics driver `$$Token' not recognized!\n"
998 " Setting graphics driver to `default'.\n");
999 graphicsDriver = "default";
1006 string const BufferParams::paperSizeName() const
1008 char real_papersize = papersize;
1009 if (real_papersize == PAPER_DEFAULT)
1010 real_papersize = lyxrc.default_papersize;
1012 switch (real_papersize) {
1021 case PAPER_EXECUTIVEPAPER:
1023 case PAPER_LEGALPAPER:
1025 case PAPER_USLETTER:
1032 string const BufferParams::dvips_options() const
1037 && papersize2 == VM_PAPER_CUSTOM
1038 && !lyxrc.print_paper_dimension_flag.empty()
1039 && !paperwidth.empty()
1040 && !paperheight.empty()) {
1041 // using a custom papersize
1042 result = lyxrc.print_paper_dimension_flag;
1043 result += ' ' + paperwidth;
1044 result += ',' + paperheight;
1046 string const paper_option = paperSizeName();
1047 if (paper_option != "letter" ||
1048 orientation != ORIENTATION_LANDSCAPE) {
1049 // dvips won't accept -t letter -t landscape.
1050 // In all other cases, include the paper size
1052 result = lyxrc.print_paper_flag;
1053 result += ' ' + paper_option;
1056 if (orientation == ORIENTATION_LANDSCAPE &&
1057 papersize2 != VM_PAPER_CUSTOM)
1058 result += ' ' + lyxrc.print_landscape_flag;