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"
19 #include "tex-strings.h"
26 #include "lyxtextclasslist.h"
34 #include "support/lyxalgo.h" // for lyx::count
35 #include "support/lyxlib.h"
36 #include "support/lstrings.h"
37 #include "support/types.h"
39 #include "frontends/Alert.h"
44 using namespace lyx::support;
51 BufferParams::BufferParams()
52 // Initialize textclass to point to article. if `first' is
53 // true in the returned pair, then `second' is the textclass
54 // number; if it is false, second is 0. In both cases, second
56 : textclass(textclasslist.NumberOfClass("article").second)
58 paragraph_separation = PARSEP_INDENT;
59 defskip = VSpace(VSpace::MEDSKIP);
60 quotes_language = InsetQuotes::EnglishQ;
61 quotes_times = InsetQuotes::DoubleQ;
65 papersize = PAPER_DEFAULT;
66 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
67 paperpackage = PACKAGE_NONE;
68 orientation = ORIENTATION_PORTRAIT;
70 use_amsmath = AMS_AUTO;
72 use_numerical_citations = false;
73 tracking_changes = false;
76 language = default_language;
79 graphicsDriver = "default";
80 sides = LyXTextClass::OneSide;
82 pagestyle = "default";
84 for (int iter = 0; iter < 4; ++iter) {
85 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
86 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
91 string const BufferParams::readToken(LyXLex & lex, string const & token)
93 if (token == "\\textclass") {
95 string const classname = lex.getString();
96 pair<bool, lyx::textclass_type> pp =
97 textclasslist.NumberOfClass(classname);
99 textclass = pp.second;
104 if (!getLyXTextClass().isTeXClassAvailable()) {
105 string msg = bformat(_("The document uses a missing "
106 "TeX class \"%1$s\".\n"), classname);
107 Alert::warning(_("Document class not available"),
108 msg + _("LyX will not be able to produce output."));
110 } else if (token == "\\begin_preamble") {
112 } else if (token == "\\options") {
114 options = lex.getString();
115 } else if (token == "\\language") {
117 } else if (token == "\\inputencoding") {
119 inputenc = lex.getString();
120 } else if (token == "\\graphics") {
121 readGraphicsDriver(lex);
122 } else if (token == "\\fontscheme") {
124 fonts = lex.getString();
125 } else if (token == "\\paragraph_separation") {
126 int tmpret = lex.findToken(string_paragraph_separation);
129 paragraph_separation =
130 static_cast<PARSEP>(tmpret);
131 } else if (token == "\\defskip") {
133 defskip = VSpace(lex.getString());
134 } else if (token == "\\quotes_language") {
135 // FIXME: should be params.readQuotes()
136 int tmpret = lex.findToken(string_quotes_language);
139 InsetQuotes::quote_language tmpl =
140 InsetQuotes::EnglishQ;
143 tmpl = InsetQuotes::EnglishQ;
146 tmpl = InsetQuotes::SwedishQ;
149 tmpl = InsetQuotes::GermanQ;
152 tmpl = InsetQuotes::PolishQ;
155 tmpl = InsetQuotes::FrenchQ;
158 tmpl = InsetQuotes::DanishQ;
161 quotes_language = tmpl;
162 } else if (token == "\\quotes_times") {
163 // FIXME: should be params.readQuotes()
165 switch (lex.getInteger()) {
167 quotes_times = InsetQuotes::SingleQ;
170 quotes_times = InsetQuotes::DoubleQ;
173 } else if (token == "\\papersize") {
174 int tmpret = lex.findToken(string_papersize);
178 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
179 } else if (token == "\\paperpackage") {
180 int tmpret = lex.findToken(string_paperpackages);
183 paperpackage = PACKAGE_NONE;
185 paperpackage = PAPER_PACKAGES(tmpret);
186 } else if (token == "\\use_geometry") {
188 use_geometry = lex.getInteger();
189 } else if (token == "\\use_amsmath") {
191 use_amsmath = static_cast<AMS>(
193 } else if (token == "\\use_natbib") {
195 use_natbib = lex.getInteger();
196 } else if (token == "\\use_numerical_citations") {
198 use_numerical_citations = lex.getInteger();
199 } else if (token == "\\tracking_changes") {
201 tracking_changes = lex.getInteger();
202 } else if (token == "\\branch") {
204 string branch = lex.getString();
205 branchlist.add(branch);
208 string const tok = lex.getString();
209 if (tok == "\\end_branch")
211 if (tok == "\\selected") {
213 branchlist.setSelected(branch, lex.getInteger());
215 // not yet operational
216 if (tok == "\\color") {
218 string color = lex.getString();
219 branchlist.setColor(branch, color);
220 // Update also the LColor table:
222 color = lcolor.getX11Name(LColor::background);
223 lcolor.fill(static_cast<LColor::color>(lcolor.size()),
227 } else if (token == "\\author") {
229 istringstream ss(STRCONV(lex.getString()));
232 author_map.push_back(authorlist.record(a));
233 } else if (token == "\\paperorientation") {
234 int tmpret = lex.findToken(string_orientation);
238 static_cast<PAPER_ORIENTATION>(tmpret);
239 } else if (token == "\\paperwidth") {
241 paperwidth = lex.getString();
242 } else if (token == "\\paperheight") {
244 paperheight = lex.getString();
245 } else if (token == "\\leftmargin") {
247 leftmargin = lex.getString();
248 } else if (token == "\\topmargin") {
250 topmargin = lex.getString();
251 } else if (token == "\\rightmargin") {
253 rightmargin = lex.getString();
254 } else if (token == "\\bottommargin") {
256 bottommargin = lex.getString();
257 } else if (token == "\\headheight") {
259 headheight = lex.getString();
260 } else if (token == "\\headsep") {
262 headsep = lex.getString();
263 } else if (token == "\\footskip") {
265 footskip = lex.getString();
266 } else if (token == "\\paperfontsize") {
268 fontsize = rtrim(lex.getString());
269 } else if (token == "\\papercolumns") {
271 columns = lex.getInteger();
272 } else if (token == "\\papersides") {
274 switch (lex.getInteger()) {
276 case 1: sides = LyXTextClass::OneSide; break;
277 case 2: sides = LyXTextClass::TwoSides; break;
279 } else if (token == "\\paperpagestyle") {
281 pagestyle = rtrim(lex.getString());
282 } else if (token == "\\bullet") {
283 // FIXME: should be params.readBullets()
285 int const index = lex.getInteger();
287 int temp_int = lex.getInteger();
288 user_defined_bullets[index].setFont(temp_int);
289 temp_bullets[index].setFont(temp_int);
291 temp_int = lex.getInteger();
292 user_defined_bullets[index].setCharacter(temp_int);
293 temp_bullets[index].setCharacter(temp_int);
295 temp_int = lex.getInteger();
296 user_defined_bullets[index].setSize(temp_int);
297 temp_bullets[index].setSize(temp_int);
299 string const temp_str = lex.getString();
300 if (temp_str != "\\end_bullet") {
301 // this element isn't really necessary for
302 // parsing but is easier for humans
303 // to understand bullets. Put it back and
304 // set a debug message?
305 lex.printError("\\end_bullet expected, got" + temp_str);
306 //how can I put it back?
308 } else if (token == "\\bulletLaTeX") {
309 // The bullet class should be able to read this.
311 int const index = lex.getInteger();
313 string temp_str = lex.getString();
315 while (temp_str != "\\end_bullet") {
316 // this loop structure is needed when user
317 // enters an empty string since the first
318 // thing returned will be the \\end_bullet
320 // if the LaTeX entry has spaces. Each element
321 // therefore needs to be read in turn
324 temp_str = lex.getString();
327 user_defined_bullets[index].setText(sum_str);
328 temp_bullets[index].setText(sum_str);
329 } else if (token == "\\secnumdepth") {
331 secnumdepth = lex.getInteger();
332 } else if (token == "\\tocdepth") {
334 tocdepth = lex.getInteger();
335 } else if (token == "\\spacing") {
337 string const tmp = rtrim(lex.getString());
338 Spacing::Space tmp_space = Spacing::Default;
340 if (tmp == "single") {
341 tmp_space = Spacing::Single;
342 } else if (tmp == "onehalf") {
343 tmp_space = Spacing::Onehalf;
344 } else if (tmp == "double") {
345 tmp_space = Spacing::Double;
346 } else if (tmp == "other") {
348 tmp_space = Spacing::Other;
349 tmp_val = lex.getFloat();
351 lex.printError("Unknown spacing token: '$$Token'");
353 #if 0 // FIXME: Handled in lyx2lyx ?
354 // Small hack so that files written with klyx will be
357 par->params().spacing(Spacing(tmp_space, tmp_val));
359 spacing.set(tmp_space, tmp_val);
360 } else if (token == "\\float_placement") {
362 float_placement = lex.getString();
371 void BufferParams::writeFile(ostream & os) const
373 // The top of the file is written by the buffer.
374 // Prints out the buffer info into the .lyx file given by file
377 os << "\\textclass " << textclasslist[textclass].name() << '\n';
379 // then the the preamble
380 if (!preamble.empty()) {
381 // remove '\n' from the end of preamble
382 string const tmppreamble = rtrim(preamble, "\n");
383 os << "\\begin_preamble\n"
385 << "\n\\end_preamble\n";
389 if (!options.empty()) {
390 os << "\\options " << options << '\n';
393 /* then the text parameters */
394 if (language != ignore_language)
395 os << "\\language " << language->lang() << '\n';
396 os << "\\inputencoding " << inputenc
397 << "\n\\fontscheme " << fonts
398 << "\n\\graphics " << graphicsDriver << '\n';
400 if (!float_placement.empty()) {
401 os << "\\float_placement " << float_placement << '\n';
403 os << "\\paperfontsize " << fontsize << '\n';
405 spacing.writeFile(os);
407 os << "\\papersize " << string_papersize[papersize2]
408 << "\n\\paperpackage " << string_paperpackages[paperpackage]
409 << "\n\\use_geometry " << use_geometry
410 << "\n\\use_amsmath " << use_amsmath
411 << "\n\\use_natbib " << use_natbib
412 << "\n\\use_numerical_citations " << use_numerical_citations
413 << "\n\\paperorientation " << string_orientation[orientation]
416 std::list<Branch>::const_iterator it = branchlist.begin();
417 std::list<Branch>::const_iterator end = branchlist.end();
418 for (; it != end; ++it) {
419 os << "\\branch " << it->getBranch()
420 << "\n\\selected " << it->getSelected()
421 << "\n\\color " << it->getColor()
426 if (!paperwidth.empty())
427 os << "\\paperwidth "
428 << VSpace(paperwidth).asLyXCommand() << '\n';
429 if (!paperheight.empty())
430 os << "\\paperheight "
431 << VSpace(paperheight).asLyXCommand() << '\n';
432 if (!leftmargin.empty())
433 os << "\\leftmargin "
434 << VSpace(leftmargin).asLyXCommand() << '\n';
435 if (!topmargin.empty())
437 << VSpace(topmargin).asLyXCommand() << '\n';
438 if (!rightmargin.empty())
439 os << "\\rightmargin "
440 << VSpace(rightmargin).asLyXCommand() << '\n';
441 if (!bottommargin.empty())
442 os << "\\bottommargin "
443 << VSpace(bottommargin).asLyXCommand() << '\n';
444 if (!headheight.empty())
445 os << "\\headheight "
446 << VSpace(headheight).asLyXCommand() << '\n';
447 if (!headsep.empty())
449 << VSpace(headsep).asLyXCommand() << '\n';
450 if (!footskip.empty())
452 << VSpace(footskip).asLyXCommand() << '\n';
453 os << "\\secnumdepth " << secnumdepth
454 << "\n\\tocdepth " << tocdepth
455 << "\n\\paragraph_separation "
456 << string_paragraph_separation[paragraph_separation]
457 << "\n\\defskip " << defskip.asLyXCommand()
458 << "\n\\quotes_language "
459 << string_quotes_language[quotes_language] << '\n';
460 switch (quotes_times) {
461 // An output operator for insetquotes would be nice
462 case InsetQuotes::SingleQ:
463 os << "\\quotes_times 1\n"; break;
464 case InsetQuotes::DoubleQ:
465 os << "\\quotes_times 2\n"; break;
467 os << "\\papercolumns " << columns
468 << "\n\\papersides " << sides
469 << "\n\\paperpagestyle " << pagestyle << '\n';
470 for (int i = 0; i < 4; ++i) {
471 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
472 if (user_defined_bullets[i].getFont() != -1) {
473 os << "\\bullet " << i
475 << user_defined_bullets[i].getFont()
477 << user_defined_bullets[i].getCharacter()
479 << user_defined_bullets[i].getSize()
480 << "\n\\end_bullet\n";
483 os << "\\bulletLaTeX " << i
485 << user_defined_bullets[i].getText()
486 << "\"\n\\end_bullet\n";
491 os << "\\tracking_changes " << tracking_changes << "\n";
493 if (tracking_changes) {
494 AuthorList::Authors::const_iterator it = authorlist.begin();
495 AuthorList::Authors::const_iterator end = authorlist.end();
496 for (; it != end; ++it) {
497 os << "\\author " << it->second << "\n";
503 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
504 TexRow & texrow) const
506 os << "\\documentclass";
508 LyXTextClass const & tclass = getLyXTextClass();
510 ostringstream clsoptions; // the document class options.
512 if (tokenPos(tclass.opt_fontsize(),
513 '|', fontsize) >= 0) {
514 // only write if existing in list (and not default)
515 clsoptions << fontsize << "pt,";
520 (paperpackage == PACKAGE_NONE)) {
523 clsoptions << "a3paper,";
526 clsoptions << "a4paper,";
529 clsoptions << "letterpaper,";
532 clsoptions << "a5paper,";
535 clsoptions << "b5paper,";
537 case PAPER_EXECUTIVEPAPER:
538 clsoptions << "executivepaper,";
540 case PAPER_LEGALPAPER:
541 clsoptions << "legalpaper,";
549 if (sides != tclass.sides()) {
551 case LyXTextClass::OneSide:
552 clsoptions << "oneside,";
554 case LyXTextClass::TwoSides:
555 clsoptions << "twoside,";
561 if (columns != tclass.columns()) {
563 clsoptions << "twocolumn,";
565 clsoptions << "onecolumn,";
569 && orientation == ORIENTATION_LANDSCAPE)
570 clsoptions << "landscape,";
572 // language should be a parameter to \documentclass
573 if (language->babel() == "hebrew"
574 && default_language->babel() != "hebrew")
575 // This seems necessary
576 features.useLanguage(default_language);
578 ostringstream language_options;
579 bool const use_babel = features.useBabel();
581 language_options << features.getLanguages();
582 language_options << language->babel();
583 if (lyxrc.language_global_options)
584 clsoptions << language_options.str() << ',';
587 // the user-defined options
588 if (!options.empty()) {
589 clsoptions << options << ',';
592 string strOptions(STRCONV(clsoptions.str()));
593 if (!strOptions.empty()) {
594 strOptions = rtrim(strOptions, ",");
595 os << '[' << strOptions << ']';
598 os << '{' << tclass.latexname() << "}\n";
600 // end of \documentclass defs
602 // font selection must be done before loading fontenc.sty
603 // The ae package is not needed when using OT1 font encoding.
604 if (fonts != "default" &&
605 (fonts != "ae" || lyxrc.fontenc != "default")) {
606 os << "\\usepackage{" << fonts << "}\n";
609 os << "\\usepackage{aecompl}\n";
613 // this one is not per buffer
614 if (lyxrc.fontenc != "default") {
615 os << "\\usepackage[" << lyxrc.fontenc
620 if (inputenc == "auto") {
621 string const doc_encoding =
622 language->encoding()->LatexName();
624 // Create a list with all the input encodings used
626 std::set<string> encodings =
627 features.getEncodingSet(doc_encoding);
629 os << "\\usepackage[";
630 std::copy(encodings.begin(), encodings.end(),
631 std::ostream_iterator<string>(os, ","));
632 os << doc_encoding << "]{inputenc}\n";
634 } else if (inputenc != "default") {
635 os << "\\usepackage[" << inputenc
640 // At the very beginning the text parameters.
641 if (paperpackage != PACKAGE_NONE) {
642 switch (paperpackage) {
646 os << "\\usepackage{a4}\n";
650 os << "\\usepackage{a4wide}\n";
653 case PACKAGE_WIDEMARGINSA4:
654 os << "\\usepackage[widemargins]{a4}\n";
660 os << "\\usepackage{geometry}\n";
662 os << "\\geometry{verbose";
663 if (orientation == ORIENTATION_LANDSCAPE)
665 switch (papersize2) {
666 case VM_PAPER_CUSTOM:
667 if (!paperwidth.empty())
670 if (!paperheight.empty())
671 os << ",paperheight="
674 case VM_PAPER_USLETTER:
675 os << ",letterpaper";
677 case VM_PAPER_USLEGAL:
680 case VM_PAPER_USEXECUTIVE:
681 os << ",executivepaper";
702 // default papersize ie VM_PAPER_DEFAULT
703 switch (lyxrc.default_papersize) {
704 case PAPER_DEFAULT: // keep compiler happy
706 os << ",letterpaper";
708 case PAPER_LEGALPAPER:
711 case PAPER_EXECUTIVEPAPER:
712 os << ",executivepaper";
728 if (!topmargin.empty())
729 os << ",tmargin=" << topmargin;
730 if (!bottommargin.empty())
731 os << ",bmargin=" << bottommargin;
732 if (!leftmargin.empty())
733 os << ",lmargin=" << leftmargin;
734 if (!rightmargin.empty())
735 os << ",rmargin=" << rightmargin;
736 if (!headheight.empty())
737 os << ",headheight=" << headheight;
738 if (!headsep.empty())
739 os << ",headsep=" << headsep;
740 if (!footskip.empty())
741 os << ",footskip=" << footskip;
746 if (tokenPos(tclass.opt_pagestyle(),
747 '|', pagestyle) >= 0) {
748 if (pagestyle == "fancy") {
749 os << "\\usepackage{fancyhdr}\n";
752 os << "\\pagestyle{" << pagestyle << "}\n";
756 if (secnumdepth != tclass.secnumdepth()) {
757 os << "\\setcounter{secnumdepth}{"
762 if (tocdepth != tclass.tocdepth()) {
763 os << "\\setcounter{tocdepth}{"
769 if (paragraph_separation) {
770 switch (defskip.kind()) {
771 case VSpace::SMALLSKIP:
772 os << "\\setlength\\parskip{\\smallskipamount}\n";
774 case VSpace::MEDSKIP:
775 os << "\\setlength\\parskip{\\medskipamount}\n";
777 case VSpace::BIGSKIP:
778 os << "\\setlength\\parskip{\\bigskipamount}\n";
781 os << "\\setlength\\parskip{"
782 << defskip.length().asLatexString()
785 default: // should never happen // Then delete it.
786 os << "\\setlength\\parskip{\\medskipamount}\n";
791 os << "\\setlength\\parindent{0pt}\n";
795 // Now insert the LyX specific LaTeX commands...
797 // The optional packages;
798 string lyxpreamble(features.getPackages());
800 // this might be useful...
801 lyxpreamble += "\n\\makeatletter\n";
803 // Some macros LyX will need
804 string tmppreamble(features.getMacros());
806 if (!tmppreamble.empty()) {
807 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
808 "LyX specific LaTeX commands.\n"
809 + tmppreamble + '\n';
812 // the text class specific preamble
813 tmppreamble = features.getTClassPreamble();
814 if (!tmppreamble.empty()) {
815 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
816 "Textclass specific LaTeX commands.\n"
817 + tmppreamble + '\n';
820 /* the user-defined preamble */
821 if (!preamble.empty()) {
822 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
823 "User specified LaTeX commands.\n"
827 // Itemize bullet settings need to be last in case the user
828 // defines their own bullets that use a package included
829 // in the user-defined preamble -- ARRae
830 // Actually it has to be done much later than that
831 // since some packages like frenchb make modifications
832 // at \begin{document} time -- JMarc
834 for (int i = 0; i < 4; ++i) {
835 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
836 if (bullets_def.empty())
837 bullets_def="\\AtBeginDocument{\n";
838 bullets_def += " \\renewcommand{\\labelitemi";
840 // `i' is one less than the item to modify
853 bullets_def += "}{" +
854 user_defined_bullets[i].getText()
859 if (!bullets_def.empty())
860 lyxpreamble += bullets_def + "}\n\n";
862 // We try to load babel late, in case it interferes
863 // with other packages.
865 string tmp = lyxrc.language_package;
866 if (!lyxrc.language_global_options
867 && tmp == "\\usepackage{babel}")
868 tmp = string("\\usepackage[") +
869 STRCONV(language_options.str()) +
871 lyxpreamble += tmp + "\n";
872 lyxpreamble += features.getBabelOptions();
875 lyxpreamble += "\\makeatother\n";
877 // dvipost settings come after everything else
878 if (tracking_changes) {
881 "\\dvipost{osstart color push Red}\n"
882 "\\dvipost{osend color pop}\n"
883 "\\dvipost{cbstart color push Blue}\n"
884 "\\dvipost{cbend color pop} \n";
888 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
889 for (int j = 0; j != nlines; ++j) {
897 void BufferParams::setPaperStuff()
899 papersize = PAPER_DEFAULT;
900 char const c1 = paperpackage;
901 if (c1 == PACKAGE_NONE) {
902 char const c2 = papersize2;
903 if (c2 == VM_PAPER_USLETTER)
904 papersize = PAPER_USLETTER;
905 else if (c2 == VM_PAPER_USLEGAL)
906 papersize = PAPER_LEGALPAPER;
907 else if (c2 == VM_PAPER_USEXECUTIVE)
908 papersize = PAPER_EXECUTIVEPAPER;
909 else if (c2 == VM_PAPER_A3)
910 papersize = PAPER_A3PAPER;
911 else if (c2 == VM_PAPER_A4)
912 papersize = PAPER_A4PAPER;
913 else if (c2 == VM_PAPER_A5)
914 papersize = PAPER_A5PAPER;
915 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
917 papersize = PAPER_B5PAPER;
918 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
919 (c1 == PACKAGE_WIDEMARGINSA4))
920 papersize = PAPER_A4PAPER;
924 void BufferParams::useClassDefaults()
926 LyXTextClass const & tclass = textclasslist[textclass];
928 sides = tclass.sides();
929 columns = tclass.columns();
930 pagestyle = tclass.pagestyle();
931 options = tclass.options();
932 secnumdepth = tclass.secnumdepth();
933 tocdepth = tclass.tocdepth();
937 bool BufferParams::hasClassDefaults() const
939 LyXTextClass const & tclass = textclasslist[textclass];
941 return (sides == tclass.sides()
942 && columns == tclass.columns()
943 && pagestyle == tclass.pagestyle()
944 && options == tclass.options()
945 && secnumdepth == tclass.secnumdepth()
946 && tocdepth == tclass.tocdepth());
950 LyXTextClass const & BufferParams::getLyXTextClass() const
952 return textclasslist[textclass];
956 void BufferParams::readPreamble(LyXLex & lex)
958 if (lex.getString() != "\\begin_preamble")
959 lyxerr << "Error (BufferParams::readPreamble):"
960 "consistency check failed." << endl;
962 preamble = lex.getLongString("\\end_preamble");
966 void BufferParams::readLanguage(LyXLex & lex)
968 if (!lex.next()) return;
970 string const tmptok = lex.getString();
972 // check if tmptok is part of tex_babel in tex-defs.h
973 language = languages.getLanguage(tmptok);
975 // Language tmptok was not found
976 language = default_language;
977 lyxerr << "Warning: Setting language `"
978 << tmptok << "' to `" << language->lang()
984 void BufferParams::readGraphicsDriver(LyXLex & lex)
986 if (!lex.next()) return;
988 string const tmptok = lex.getString();
989 // check if tmptok is part of tex_graphics in tex_defs.h
992 string const test = tex_graphics[n++];
994 if (test == tmptok) {
995 graphicsDriver = tmptok;
997 } else if (test == "last_item") {
999 "Warning: graphics driver `$$Token' not recognized!\n"
1000 " Setting graphics driver to `default'.\n");
1001 graphicsDriver = "default";
1008 string const BufferParams::paperSizeName() const
1010 char real_papersize = papersize;
1011 if (real_papersize == PAPER_DEFAULT)
1012 real_papersize = lyxrc.default_papersize;
1014 switch (real_papersize) {
1023 case PAPER_EXECUTIVEPAPER:
1025 case PAPER_LEGALPAPER:
1027 case PAPER_USLETTER:
1034 string const BufferParams::dvips_options() const
1039 && papersize2 == VM_PAPER_CUSTOM
1040 && !lyxrc.print_paper_dimension_flag.empty()
1041 && !paperwidth.empty()
1042 && !paperheight.empty()) {
1043 // using a custom papersize
1044 result = lyxrc.print_paper_dimension_flag;
1045 result += ' ' + paperwidth;
1046 result += ',' + paperheight;
1048 string const paper_option = paperSizeName();
1049 if (paper_option != "letter" ||
1050 orientation != ORIENTATION_LANDSCAPE) {
1051 // dvips won't accept -t letter -t landscape.
1052 // In all other cases, include the paper size
1054 result = lyxrc.print_paper_flag;
1055 result += ' ' + paper_option;
1058 if (orientation == ORIENTATION_LANDSCAPE &&
1059 papersize2 != VM_PAPER_CUSTOM)
1060 result += ' ' + lyxrc.print_landscape_flag;