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"
23 #include "LaTeXFeatures.h"
24 #include "support/std_sstream.h"
26 #include "lyxtextclasslist.h"
27 #include "tex-strings.h"
30 #include "frontends/Alert.h"
32 #include "support/lyxalgo.h" // for lyx::count
35 using namespace lyx::support;
42 BufferParams::BufferParams()
43 // Initialize textclass to point to article. if `first' is
44 // true in the returned pair, then `second' is the textclass
45 // number; if it is false, second is 0. In both cases, second
47 : textclass(textclasslist.NumberOfClass("article").second)
49 paragraph_separation = PARSEP_INDENT;
50 defskip = VSpace(VSpace::MEDSKIP);
51 quotes_language = InsetQuotes::EnglishQ;
52 quotes_times = InsetQuotes::DoubleQ;
56 papersize = PAPER_DEFAULT;
57 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
58 paperpackage = PACKAGE_NONE;
59 orientation = ORIENTATION_PORTRAIT;
61 use_amsmath = AMS_AUTO;
63 use_numerical_citations = false;
64 tracking_changes = false;
67 language = default_language;
70 graphicsDriver = "default";
71 sides = LyXTextClass::OneSide;
73 pagestyle = "default";
75 for (int iter = 0; iter < 4; ++iter) {
76 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
77 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
82 string const BufferParams::readToken(LyXLex & lex, string const & token)
84 if (token == "\\textclass") {
86 string const classname = lex.getString();
87 pair<bool, lyx::textclass_type> pp =
88 textclasslist.NumberOfClass(classname);
90 textclass = pp.second;
95 if (!getLyXTextClass().isTeXClassAvailable()) {
96 string msg = bformat(_("The document uses a missing "
97 "TeX class \"%1$s\".\n"), classname);
98 Alert::warning(_("Document class not available"),
99 msg + _("LyX will not be able to produce output."));
101 } else if (token == "\\begin_preamble") {
103 } else if (token == "\\options") {
105 options = lex.getString();
106 } else if (token == "\\language") {
108 } else if (token == "\\inputencoding") {
110 inputenc = lex.getString();
111 } else if (token == "\\graphics") {
112 readGraphicsDriver(lex);
113 } else if (token == "\\fontscheme") {
115 fonts = lex.getString();
116 } else if (token == "\\paragraph_separation") {
117 int tmpret = lex.findToken(string_paragraph_separation);
120 paragraph_separation =
121 static_cast<PARSEP>(tmpret);
122 } else if (token == "\\defskip") {
124 defskip = VSpace(lex.getString());
125 } else if (token == "\\quotes_language") {
126 // FIXME: should be params.readQuotes()
127 int tmpret = lex.findToken(string_quotes_language);
130 InsetQuotes::quote_language tmpl =
131 InsetQuotes::EnglishQ;
134 tmpl = InsetQuotes::EnglishQ;
137 tmpl = InsetQuotes::SwedishQ;
140 tmpl = InsetQuotes::GermanQ;
143 tmpl = InsetQuotes::PolishQ;
146 tmpl = InsetQuotes::FrenchQ;
149 tmpl = InsetQuotes::DanishQ;
152 quotes_language = tmpl;
153 } else if (token == "\\quotes_times") {
154 // FIXME: should be params.readQuotes()
156 switch (lex.getInteger()) {
158 quotes_times = InsetQuotes::SingleQ;
161 quotes_times = InsetQuotes::DoubleQ;
164 } else if (token == "\\papersize") {
165 int tmpret = lex.findToken(string_papersize);
169 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
170 } else if (token == "\\paperpackage") {
171 int tmpret = lex.findToken(string_paperpackages);
174 paperpackage = PACKAGE_NONE;
176 paperpackage = PAPER_PACKAGES(tmpret);
177 } else if (token == "\\use_geometry") {
179 use_geometry = lex.getInteger();
180 } else if (token == "\\use_amsmath") {
182 use_amsmath = static_cast<AMS>(
184 } else if (token == "\\use_natbib") {
186 use_natbib = lex.getInteger();
187 } else if (token == "\\use_numerical_citations") {
189 use_numerical_citations = lex.getInteger();
190 } else if (token == "\\tracking_changes") {
192 tracking_changes = lex.getInteger();
193 } else if (token == "\\branch") {
195 string branch = lex.getString();
196 branchlist.add(branch);
199 string const tok = lex.getString();
200 if (tok == "\\end_branch")
202 if (tok == "\\selected") {
204 branchlist.setSelected(branch, lex.getInteger());
206 // not yet operational
207 if (tok == "\\color") {
209 string color = lex.getString();
210 branchlist.setColor(branch, color);
211 // Update also the LColor table:
213 color = lcolor.getX11Name(LColor::background);
214 lcolor.fill(static_cast<LColor::color>(lcolor.size()),
218 } else if (token == "\\author") {
220 istringstream ss(STRCONV(lex.getString()));
223 author_map.push_back(authorlist.record(a));
224 } else if (token == "\\paperorientation") {
225 int tmpret = lex.findToken(string_orientation);
229 static_cast<PAPER_ORIENTATION>(tmpret);
230 } else if (token == "\\paperwidth") {
232 paperwidth = lex.getString();
233 } else if (token == "\\paperheight") {
235 paperheight = lex.getString();
236 } else if (token == "\\leftmargin") {
238 leftmargin = lex.getString();
239 } else if (token == "\\topmargin") {
241 topmargin = lex.getString();
242 } else if (token == "\\rightmargin") {
244 rightmargin = lex.getString();
245 } else if (token == "\\bottommargin") {
247 bottommargin = lex.getString();
248 } else if (token == "\\headheight") {
250 headheight = lex.getString();
251 } else if (token == "\\headsep") {
253 headsep = lex.getString();
254 } else if (token == "\\footskip") {
256 footskip = lex.getString();
257 } else if (token == "\\paperfontsize") {
259 fontsize = rtrim(lex.getString());
260 } else if (token == "\\papercolumns") {
262 columns = lex.getInteger();
263 } else if (token == "\\papersides") {
265 switch (lex.getInteger()) {
267 case 1: sides = LyXTextClass::OneSide; break;
268 case 2: sides = LyXTextClass::TwoSides; break;
270 } else if (token == "\\paperpagestyle") {
272 pagestyle = rtrim(lex.getString());
273 } else if (token == "\\bullet") {
274 // FIXME: should be params.readBullets()
276 int const index = lex.getInteger();
278 int temp_int = lex.getInteger();
279 user_defined_bullets[index].setFont(temp_int);
280 temp_bullets[index].setFont(temp_int);
282 temp_int = lex.getInteger();
283 user_defined_bullets[index].setCharacter(temp_int);
284 temp_bullets[index].setCharacter(temp_int);
286 temp_int = lex.getInteger();
287 user_defined_bullets[index].setSize(temp_int);
288 temp_bullets[index].setSize(temp_int);
290 string const temp_str = lex.getString();
291 if (temp_str != "\\end_bullet") {
292 // this element isn't really necessary for
293 // parsing but is easier for humans
294 // to understand bullets. Put it back and
295 // set a debug message?
296 lex.printError("\\end_bullet expected, got" + temp_str);
297 //how can I put it back?
299 } else if (token == "\\bulletLaTeX") {
300 // The bullet class should be able to read this.
302 int const index = lex.getInteger();
304 string temp_str = lex.getString();
306 while (temp_str != "\\end_bullet") {
307 // this loop structure is needed when user
308 // enters an empty string since the first
309 // thing returned will be the \\end_bullet
311 // if the LaTeX entry has spaces. Each element
312 // therefore needs to be read in turn
315 temp_str = lex.getString();
318 user_defined_bullets[index].setText(sum_str);
319 temp_bullets[index].setText(sum_str);
320 } else if (token == "\\secnumdepth") {
322 secnumdepth = lex.getInteger();
323 } else if (token == "\\tocdepth") {
325 tocdepth = lex.getInteger();
326 } else if (token == "\\spacing") {
328 string const tmp = rtrim(lex.getString());
329 Spacing::Space tmp_space = Spacing::Default;
331 if (tmp == "single") {
332 tmp_space = Spacing::Single;
333 } else if (tmp == "onehalf") {
334 tmp_space = Spacing::Onehalf;
335 } else if (tmp == "double") {
336 tmp_space = Spacing::Double;
337 } else if (tmp == "other") {
339 tmp_space = Spacing::Other;
340 tmp_val = lex.getFloat();
342 lex.printError("Unknown spacing token: '$$Token'");
344 #if 0 // FIXME: Handled in lyx2lyx ?
345 // Small hack so that files written with klyx will be
348 par->params().spacing(Spacing(tmp_space, tmp_val));
350 spacing.set(tmp_space, tmp_val);
351 } else if (token == "\\float_placement") {
353 float_placement = lex.getString();
362 void BufferParams::writeFile(ostream & os) const
364 // The top of the file is written by the buffer.
365 // Prints out the buffer info into the .lyx file given by file
368 os << "\\textclass " << textclasslist[textclass].name() << '\n';
370 // then the the preamble
371 if (!preamble.empty()) {
372 // remove '\n' from the end of preamble
373 string const tmppreamble = rtrim(preamble, "\n");
374 os << "\\begin_preamble\n"
376 << "\n\\end_preamble\n";
380 if (!options.empty()) {
381 os << "\\options " << options << '\n';
384 /* then the text parameters */
385 if (language != ignore_language)
386 os << "\\language " << language->lang() << '\n';
387 os << "\\inputencoding " << inputenc
388 << "\n\\fontscheme " << fonts
389 << "\n\\graphics " << graphicsDriver << '\n';
391 if (!float_placement.empty()) {
392 os << "\\float_placement " << float_placement << '\n';
394 os << "\\paperfontsize " << fontsize << '\n';
396 spacing.writeFile(os);
398 os << "\\papersize " << string_papersize[papersize2]
399 << "\n\\paperpackage " << string_paperpackages[paperpackage]
400 << "\n\\use_geometry " << use_geometry
401 << "\n\\use_amsmath " << use_amsmath
402 << "\n\\use_natbib " << use_natbib
403 << "\n\\use_numerical_citations " << use_numerical_citations
404 << "\n\\paperorientation " << string_orientation[orientation]
407 std::list<Branch>::const_iterator it = branchlist.begin();
408 std::list<Branch>::const_iterator end = branchlist.end();
409 for (; it != end; ++it) {
410 os << "\\branch " << it->getBranch()
411 << "\n\\selected " << it->getSelected()
412 << "\n\\color " << it->getColor()
417 if (!paperwidth.empty())
418 os << "\\paperwidth "
419 << VSpace(paperwidth).asLyXCommand() << '\n';
420 if (!paperheight.empty())
421 os << "\\paperheight "
422 << VSpace(paperheight).asLyXCommand() << '\n';
423 if (!leftmargin.empty())
424 os << "\\leftmargin "
425 << VSpace(leftmargin).asLyXCommand() << '\n';
426 if (!topmargin.empty())
428 << VSpace(topmargin).asLyXCommand() << '\n';
429 if (!rightmargin.empty())
430 os << "\\rightmargin "
431 << VSpace(rightmargin).asLyXCommand() << '\n';
432 if (!bottommargin.empty())
433 os << "\\bottommargin "
434 << VSpace(bottommargin).asLyXCommand() << '\n';
435 if (!headheight.empty())
436 os << "\\headheight "
437 << VSpace(headheight).asLyXCommand() << '\n';
438 if (!headsep.empty())
440 << VSpace(headsep).asLyXCommand() << '\n';
441 if (!footskip.empty())
443 << VSpace(footskip).asLyXCommand() << '\n';
444 os << "\\secnumdepth " << secnumdepth
445 << "\n\\tocdepth " << tocdepth
446 << "\n\\paragraph_separation "
447 << string_paragraph_separation[paragraph_separation]
448 << "\n\\defskip " << defskip.asLyXCommand()
449 << "\n\\quotes_language "
450 << string_quotes_language[quotes_language] << '\n';
451 switch (quotes_times) {
452 // An output operator for insetquotes would be nice
453 case InsetQuotes::SingleQ:
454 os << "\\quotes_times 1\n"; break;
455 case InsetQuotes::DoubleQ:
456 os << "\\quotes_times 2\n"; break;
458 os << "\\papercolumns " << columns
459 << "\n\\papersides " << sides
460 << "\n\\paperpagestyle " << pagestyle << '\n';
461 for (int i = 0; i < 4; ++i) {
462 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
463 if (user_defined_bullets[i].getFont() != -1) {
464 os << "\\bullet " << i
466 << user_defined_bullets[i].getFont()
468 << user_defined_bullets[i].getCharacter()
470 << user_defined_bullets[i].getSize()
471 << "\n\\end_bullet\n";
474 os << "\\bulletLaTeX " << i
476 << user_defined_bullets[i].getText()
477 << "\"\n\\end_bullet\n";
482 os << "\\tracking_changes " << tracking_changes << "\n";
484 if (tracking_changes) {
485 AuthorList::Authors::const_iterator it = authorlist.begin();
486 AuthorList::Authors::const_iterator end = authorlist.end();
487 for (; it != end; ++it) {
488 os << "\\author " << it->second << "\n";
494 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
495 TexRow & texrow) const
497 os << "\\documentclass";
499 LyXTextClass const & tclass = getLyXTextClass();
501 ostringstream clsoptions; // the document class options.
503 if (tokenPos(tclass.opt_fontsize(),
504 '|', fontsize) >= 0) {
505 // only write if existing in list (and not default)
506 clsoptions << fontsize << "pt,";
511 (paperpackage == PACKAGE_NONE)) {
514 clsoptions << "a3paper,";
517 clsoptions << "a4paper,";
520 clsoptions << "letterpaper,";
523 clsoptions << "a5paper,";
526 clsoptions << "b5paper,";
528 case PAPER_EXECUTIVEPAPER:
529 clsoptions << "executivepaper,";
531 case PAPER_LEGALPAPER:
532 clsoptions << "legalpaper,";
540 if (sides != tclass.sides()) {
542 case LyXTextClass::OneSide:
543 clsoptions << "oneside,";
545 case LyXTextClass::TwoSides:
546 clsoptions << "twoside,";
552 if (columns != tclass.columns()) {
554 clsoptions << "twocolumn,";
556 clsoptions << "onecolumn,";
560 && orientation == ORIENTATION_LANDSCAPE)
561 clsoptions << "landscape,";
563 // language should be a parameter to \documentclass
564 if (language->babel() == "hebrew"
565 && default_language->babel() != "hebrew")
566 // This seems necessary
567 features.useLanguage(default_language);
569 ostringstream language_options;
570 bool const use_babel = features.useBabel();
572 language_options << features.getLanguages();
573 language_options << language->babel();
574 if (lyxrc.language_global_options)
575 clsoptions << language_options.str() << ',';
578 // the user-defined options
579 if (!options.empty()) {
580 clsoptions << options << ',';
583 string strOptions(STRCONV(clsoptions.str()));
584 if (!strOptions.empty()) {
585 strOptions = rtrim(strOptions, ",");
586 os << '[' << strOptions << ']';
589 os << '{' << tclass.latexname() << "}\n";
591 // end of \documentclass defs
593 // font selection must be done before loading fontenc.sty
594 // The ae package is not needed when using OT1 font encoding.
595 if (fonts != "default" &&
596 (fonts != "ae" || lyxrc.fontenc != "default")) {
597 os << "\\usepackage{" << fonts << "}\n";
600 os << "\\usepackage{aecompl}\n";
604 // this one is not per buffer
605 if (lyxrc.fontenc != "default") {
606 os << "\\usepackage[" << lyxrc.fontenc
611 if (inputenc == "auto") {
612 string const doc_encoding =
613 language->encoding()->LatexName();
615 // Create a list with all the input encodings used
617 std::set<string> encodings =
618 features.getEncodingSet(doc_encoding);
620 os << "\\usepackage[";
621 std::copy(encodings.begin(), encodings.end(),
622 std::ostream_iterator<string>(os, ","));
623 os << doc_encoding << "]{inputenc}\n";
625 } else if (inputenc != "default") {
626 os << "\\usepackage[" << inputenc
631 // At the very beginning the text parameters.
632 if (paperpackage != PACKAGE_NONE) {
633 switch (paperpackage) {
637 os << "\\usepackage{a4}\n";
641 os << "\\usepackage{a4wide}\n";
644 case PACKAGE_WIDEMARGINSA4:
645 os << "\\usepackage[widemargins]{a4}\n";
651 os << "\\usepackage{geometry}\n";
653 os << "\\geometry{verbose";
654 if (orientation == ORIENTATION_LANDSCAPE)
656 switch (papersize2) {
657 case VM_PAPER_CUSTOM:
658 if (!paperwidth.empty())
661 if (!paperheight.empty())
662 os << ",paperheight="
665 case VM_PAPER_USLETTER:
666 os << ",letterpaper";
668 case VM_PAPER_USLEGAL:
671 case VM_PAPER_USEXECUTIVE:
672 os << ",executivepaper";
693 // default papersize ie VM_PAPER_DEFAULT
694 switch (lyxrc.default_papersize) {
695 case PAPER_DEFAULT: // keep compiler happy
697 os << ",letterpaper";
699 case PAPER_LEGALPAPER:
702 case PAPER_EXECUTIVEPAPER:
703 os << ",executivepaper";
719 if (!topmargin.empty())
720 os << ",tmargin=" << topmargin;
721 if (!bottommargin.empty())
722 os << ",bmargin=" << bottommargin;
723 if (!leftmargin.empty())
724 os << ",lmargin=" << leftmargin;
725 if (!rightmargin.empty())
726 os << ",rmargin=" << rightmargin;
727 if (!headheight.empty())
728 os << ",headheight=" << headheight;
729 if (!headsep.empty())
730 os << ",headsep=" << headsep;
731 if (!footskip.empty())
732 os << ",footskip=" << footskip;
737 if (tokenPos(tclass.opt_pagestyle(),
738 '|', pagestyle) >= 0) {
739 if (pagestyle == "fancy") {
740 os << "\\usepackage{fancyhdr}\n";
743 os << "\\pagestyle{" << pagestyle << "}\n";
747 if (secnumdepth != tclass.secnumdepth()) {
748 os << "\\setcounter{secnumdepth}{"
753 if (tocdepth != tclass.tocdepth()) {
754 os << "\\setcounter{tocdepth}{"
760 if (paragraph_separation) {
761 switch (defskip.kind()) {
762 case VSpace::SMALLSKIP:
763 os << "\\setlength\\parskip{\\smallskipamount}\n";
765 case VSpace::MEDSKIP:
766 os << "\\setlength\\parskip{\\medskipamount}\n";
768 case VSpace::BIGSKIP:
769 os << "\\setlength\\parskip{\\bigskipamount}\n";
772 os << "\\setlength\\parskip{"
773 << defskip.length().asLatexString()
776 default: // should never happen // Then delete it.
777 os << "\\setlength\\parskip{\\medskipamount}\n";
782 os << "\\setlength\\parindent{0pt}\n";
786 // Now insert the LyX specific LaTeX commands...
788 // The optional packages;
789 string lyxpreamble(features.getPackages());
791 // this might be useful...
792 lyxpreamble += "\n\\makeatletter\n";
794 // Some macros LyX will need
795 string tmppreamble(features.getMacros());
797 if (!tmppreamble.empty()) {
798 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
799 "LyX specific LaTeX commands.\n"
800 + tmppreamble + '\n';
803 // the text class specific preamble
804 tmppreamble = features.getTClassPreamble();
805 if (!tmppreamble.empty()) {
806 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
807 "Textclass specific LaTeX commands.\n"
808 + tmppreamble + '\n';
811 /* the user-defined preamble */
812 if (!preamble.empty()) {
813 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
814 "User specified LaTeX commands.\n"
818 // Itemize bullet settings need to be last in case the user
819 // defines their own bullets that use a package included
820 // in the user-defined preamble -- ARRae
821 // Actually it has to be done much later than that
822 // since some packages like frenchb make modifications
823 // at \begin{document} time -- JMarc
825 for (int i = 0; i < 4; ++i) {
826 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
827 if (bullets_def.empty())
828 bullets_def="\\AtBeginDocument{\n";
829 bullets_def += " \\renewcommand{\\labelitemi";
831 // `i' is one less than the item to modify
844 bullets_def += "}{" +
845 user_defined_bullets[i].getText()
850 if (!bullets_def.empty())
851 lyxpreamble += bullets_def + "}\n\n";
853 // We try to load babel late, in case it interferes
854 // with other packages.
856 string tmp = lyxrc.language_package;
857 if (!lyxrc.language_global_options
858 && tmp == "\\usepackage{babel}")
859 tmp = string("\\usepackage[") +
860 STRCONV(language_options.str()) +
862 lyxpreamble += tmp + "\n";
863 lyxpreamble += features.getBabelOptions();
866 lyxpreamble += "\\makeatother\n";
868 // dvipost settings come after everything else
869 if (tracking_changes) {
872 "\\dvipost{osstart color push Red}\n"
873 "\\dvipost{osend color pop}\n"
874 "\\dvipost{cbstart color push Blue}\n"
875 "\\dvipost{cbend color pop} \n";
879 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
880 for (int j = 0; j != nlines; ++j) {
888 void BufferParams::setPaperStuff()
890 papersize = PAPER_DEFAULT;
891 char const c1 = paperpackage;
892 if (c1 == PACKAGE_NONE) {
893 char const c2 = papersize2;
894 if (c2 == VM_PAPER_USLETTER)
895 papersize = PAPER_USLETTER;
896 else if (c2 == VM_PAPER_USLEGAL)
897 papersize = PAPER_LEGALPAPER;
898 else if (c2 == VM_PAPER_USEXECUTIVE)
899 papersize = PAPER_EXECUTIVEPAPER;
900 else if (c2 == VM_PAPER_A3)
901 papersize = PAPER_A3PAPER;
902 else if (c2 == VM_PAPER_A4)
903 papersize = PAPER_A4PAPER;
904 else if (c2 == VM_PAPER_A5)
905 papersize = PAPER_A5PAPER;
906 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
908 papersize = PAPER_B5PAPER;
909 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
910 (c1 == PACKAGE_WIDEMARGINSA4))
911 papersize = PAPER_A4PAPER;
915 void BufferParams::useClassDefaults()
917 LyXTextClass const & tclass = textclasslist[textclass];
919 sides = tclass.sides();
920 columns = tclass.columns();
921 pagestyle = tclass.pagestyle();
922 options = tclass.options();
923 secnumdepth = tclass.secnumdepth();
924 tocdepth = tclass.tocdepth();
928 bool BufferParams::hasClassDefaults() const
930 LyXTextClass const & tclass = textclasslist[textclass];
932 return (sides == tclass.sides()
933 && columns == tclass.columns()
934 && pagestyle == tclass.pagestyle()
935 && options == tclass.options()
936 && secnumdepth == tclass.secnumdepth()
937 && tocdepth == tclass.tocdepth());
941 LyXTextClass const & BufferParams::getLyXTextClass() const
943 return textclasslist[textclass];
947 void BufferParams::readPreamble(LyXLex & lex)
949 if (lex.getString() != "\\begin_preamble")
950 lyxerr << "Error (BufferParams::readPreamble):"
951 "consistency check failed." << endl;
953 preamble = lex.getLongString("\\end_preamble");
957 void BufferParams::readLanguage(LyXLex & lex)
959 if (!lex.next()) return;
961 string const tmptok = lex.getString();
963 // check if tmptok is part of tex_babel in tex-defs.h
964 language = languages.getLanguage(tmptok);
966 // Language tmptok was not found
967 language = default_language;
968 lyxerr << "Warning: Setting language `"
969 << tmptok << "' to `" << language->lang()
975 void BufferParams::readGraphicsDriver(LyXLex & lex)
977 if (!lex.next()) return;
979 string const tmptok = lex.getString();
980 // check if tmptok is part of tex_graphics in tex_defs.h
983 string const test = tex_graphics[n++];
985 if (test == tmptok) {
986 graphicsDriver = tmptok;
988 } else if (test == "last_item") {
990 "Warning: graphics driver `$$Token' not recognized!\n"
991 " Setting graphics driver to `default'.\n");
992 graphicsDriver = "default";
999 string const BufferParams::paperSizeName() const
1001 char real_papersize = papersize;
1002 if (real_papersize == PAPER_DEFAULT)
1003 real_papersize = lyxrc.default_papersize;
1005 switch (real_papersize) {
1014 case PAPER_EXECUTIVEPAPER:
1016 case PAPER_LEGALPAPER:
1018 case PAPER_USLETTER:
1025 string const BufferParams::dvips_options() const
1030 && papersize2 == VM_PAPER_CUSTOM
1031 && !lyxrc.print_paper_dimension_flag.empty()
1032 && !paperwidth.empty()
1033 && !paperheight.empty()) {
1034 // using a custom papersize
1035 result = lyxrc.print_paper_dimension_flag;
1036 result += ' ' + paperwidth;
1037 result += ',' + paperheight;
1039 string const paper_option = paperSizeName();
1040 if (paper_option != "letter" ||
1041 orientation != ORIENTATION_LANDSCAPE) {
1042 // dvips won't accept -t letter -t landscape.
1043 // In all other cases, include the paper size
1045 result = lyxrc.print_paper_flag;
1046 result += ' ' + paper_option;
1049 if (orientation == ORIENTATION_LANDSCAPE &&
1050 papersize2 != VM_PAPER_CUSTOM)
1051 result += ' ' + lyxrc.print_landscape_flag;