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.
19 #include "bufferparams.h"
25 #include "LaTeXFeatures.h"
30 #include "lyxtextclasslist.h"
31 #include "tex-strings.h"
35 #include "frontends/Alert.h"
37 #include "support/lyxalgo.h" // for lyx::count
38 #include "support/lyxlib.h"
39 #include "support/lstrings.h"
40 #include "support/types.h"
45 using namespace lyx::support;
52 BufferParams::BufferParams()
53 // Initialize textclass to point to article. if `first' is
54 // true in the returned pair, then `second' is the textclass
55 // number; if it is false, second is 0. In both cases, second
57 : textclass(textclasslist.NumberOfClass("article").second)
59 paragraph_separation = PARSEP_INDENT;
60 defskip = VSpace(VSpace::MEDSKIP);
61 quotes_language = InsetQuotes::EnglishQ;
62 quotes_times = InsetQuotes::DoubleQ;
66 papersize = PAPER_DEFAULT;
67 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
68 paperpackage = PACKAGE_NONE;
69 orientation = ORIENTATION_PORTRAIT;
71 use_amsmath = AMS_AUTO;
73 use_numerical_citations = false;
74 tracking_changes = false;
77 language = default_language;
80 graphicsDriver = "default";
81 sides = LyXTextClass::OneSide;
83 pagestyle = "default";
85 for (int iter = 0; iter < 4; ++iter) {
86 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
87 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
92 string const BufferParams::readToken(LyXLex & lex, string const & token)
94 if (token == "\\textclass") {
96 string const classname = lex.getString();
97 pair<bool, lyx::textclass_type> pp =
98 textclasslist.NumberOfClass(classname);
100 textclass = pp.second;
105 if (!getLyXTextClass().isTeXClassAvailable()) {
106 string msg = bformat(_("The document uses a missing "
107 "TeX class \"%1$s\".\n"), classname);
108 Alert::warning(_("Document class not available"),
109 msg + _("LyX will not be able to produce output."));
111 } else if (token == "\\begin_preamble") {
113 } else if (token == "\\options") {
115 options = lex.getString();
116 } else if (token == "\\language") {
118 } else if (token == "\\inputencoding") {
120 inputenc = lex.getString();
121 } else if (token == "\\graphics") {
122 readGraphicsDriver(lex);
123 } else if (token == "\\fontscheme") {
125 fonts = lex.getString();
126 } else if (token == "\\paragraph_separation") {
127 int tmpret = lex.findToken(string_paragraph_separation);
130 paragraph_separation =
131 static_cast<PARSEP>(tmpret);
132 } else if (token == "\\defskip") {
134 defskip = VSpace(lex.getString());
135 } else if (token == "\\quotes_language") {
136 // FIXME: should be params.readQuotes()
137 int tmpret = lex.findToken(string_quotes_language);
140 InsetQuotes::quote_language tmpl =
141 InsetQuotes::EnglishQ;
144 tmpl = InsetQuotes::EnglishQ;
147 tmpl = InsetQuotes::SwedishQ;
150 tmpl = InsetQuotes::GermanQ;
153 tmpl = InsetQuotes::PolishQ;
156 tmpl = InsetQuotes::FrenchQ;
159 tmpl = InsetQuotes::DanishQ;
162 quotes_language = tmpl;
163 } else if (token == "\\quotes_times") {
164 // FIXME: should be params.readQuotes()
166 switch (lex.getInteger()) {
168 quotes_times = InsetQuotes::SingleQ;
171 quotes_times = InsetQuotes::DoubleQ;
174 } else if (token == "\\papersize") {
175 int tmpret = lex.findToken(string_papersize);
179 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
180 } else if (token == "\\paperpackage") {
181 int tmpret = lex.findToken(string_paperpackages);
184 paperpackage = PACKAGE_NONE;
186 paperpackage = PAPER_PACKAGES(tmpret);
187 } else if (token == "\\use_geometry") {
189 use_geometry = lex.getInteger();
190 } else if (token == "\\use_amsmath") {
192 use_amsmath = static_cast<AMS>(
194 } else if (token == "\\use_natbib") {
196 use_natbib = lex.getInteger();
197 } else if (token == "\\use_numerical_citations") {
199 use_numerical_citations = lex.getInteger();
200 } else if (token == "\\tracking_changes") {
202 tracking_changes = lex.getInteger();
203 } else if (token == "\\branch") {
205 string branch = lex.getString();
206 branchlist.add(branch);
209 string const tok = lex.getString();
210 if (tok == "\\end_branch")
212 if (tok == "\\selected") {
214 branchlist.setSelected(branch, lex.getInteger());
216 // not yet operational
217 if (tok == "\\color") {
219 string color = lex.getString();
220 branchlist.setColor(branch, color);
221 // Update also the LColor table:
223 color = lcolor.getX11Name(LColor::background);
224 lcolor.fill(static_cast<LColor::color>(lcolor.size()),
228 } else if (token == "\\author") {
230 istringstream ss(STRCONV(lex.getString()));
233 author_map.push_back(authorlist.record(a));
234 } else if (token == "\\paperorientation") {
235 int tmpret = lex.findToken(string_orientation);
239 static_cast<PAPER_ORIENTATION>(tmpret);
240 } else if (token == "\\paperwidth") {
242 paperwidth = lex.getString();
243 } else if (token == "\\paperheight") {
245 paperheight = lex.getString();
246 } else if (token == "\\leftmargin") {
248 leftmargin = lex.getString();
249 } else if (token == "\\topmargin") {
251 topmargin = lex.getString();
252 } else if (token == "\\rightmargin") {
254 rightmargin = lex.getString();
255 } else if (token == "\\bottommargin") {
257 bottommargin = lex.getString();
258 } else if (token == "\\headheight") {
260 headheight = lex.getString();
261 } else if (token == "\\headsep") {
263 headsep = lex.getString();
264 } else if (token == "\\footskip") {
266 footskip = lex.getString();
267 } else if (token == "\\paperfontsize") {
269 fontsize = rtrim(lex.getString());
270 } else if (token == "\\papercolumns") {
272 columns = lex.getInteger();
273 } else if (token == "\\papersides") {
275 switch (lex.getInteger()) {
277 case 1: sides = LyXTextClass::OneSide; break;
278 case 2: sides = LyXTextClass::TwoSides; break;
280 } else if (token == "\\paperpagestyle") {
282 pagestyle = rtrim(lex.getString());
283 } else if (token == "\\bullet") {
284 // FIXME: should be params.readBullets()
286 int const index = lex.getInteger();
288 int temp_int = lex.getInteger();
289 user_defined_bullets[index].setFont(temp_int);
290 temp_bullets[index].setFont(temp_int);
292 temp_int = lex.getInteger();
293 user_defined_bullets[index].setCharacter(temp_int);
294 temp_bullets[index].setCharacter(temp_int);
296 temp_int = lex.getInteger();
297 user_defined_bullets[index].setSize(temp_int);
298 temp_bullets[index].setSize(temp_int);
300 string const temp_str = lex.getString();
301 if (temp_str != "\\end_bullet") {
302 // this element isn't really necessary for
303 // parsing but is easier for humans
304 // to understand bullets. Put it back and
305 // set a debug message?
306 lex.printError("\\end_bullet expected, got" + temp_str);
307 //how can I put it back?
309 } else if (token == "\\bulletLaTeX") {
310 // The bullet class should be able to read this.
312 int const index = lex.getInteger();
314 string temp_str = lex.getString();
316 while (temp_str != "\\end_bullet") {
317 // this loop structure is needed when user
318 // enters an empty string since the first
319 // thing returned will be the \\end_bullet
321 // if the LaTeX entry has spaces. Each element
322 // therefore needs to be read in turn
325 temp_str = lex.getString();
328 user_defined_bullets[index].setText(sum_str);
329 temp_bullets[index].setText(sum_str);
330 } else if (token == "\\secnumdepth") {
332 secnumdepth = lex.getInteger();
333 } else if (token == "\\tocdepth") {
335 tocdepth = lex.getInteger();
336 } else if (token == "\\spacing") {
338 string const tmp = rtrim(lex.getString());
339 Spacing::Space tmp_space = Spacing::Default;
341 if (tmp == "single") {
342 tmp_space = Spacing::Single;
343 } else if (tmp == "onehalf") {
344 tmp_space = Spacing::Onehalf;
345 } else if (tmp == "double") {
346 tmp_space = Spacing::Double;
347 } else if (tmp == "other") {
349 tmp_space = Spacing::Other;
350 tmp_val = lex.getFloat();
352 lex.printError("Unknown spacing token: '$$Token'");
354 #if 0 // FIXME: Handled in lyx2lyx ?
355 // Small hack so that files written with klyx will be
358 par->params().spacing(Spacing(tmp_space, tmp_val));
360 spacing.set(tmp_space, tmp_val);
361 } else if (token == "\\float_placement") {
363 float_placement = lex.getString();
372 void BufferParams::writeFile(ostream & os) const
374 // The top of the file is written by the buffer.
375 // Prints out the buffer info into the .lyx file given by file
378 os << "\\textclass " << textclasslist[textclass].name() << '\n';
380 // then the the preamble
381 if (!preamble.empty()) {
382 // remove '\n' from the end of preamble
383 string const tmppreamble = rtrim(preamble, "\n");
384 os << "\\begin_preamble\n"
386 << "\n\\end_preamble\n";
390 if (!options.empty()) {
391 os << "\\options " << options << '\n';
394 /* then the text parameters */
395 if (language != ignore_language)
396 os << "\\language " << language->lang() << '\n';
397 os << "\\inputencoding " << inputenc
398 << "\n\\fontscheme " << fonts
399 << "\n\\graphics " << graphicsDriver << '\n';
401 if (!float_placement.empty()) {
402 os << "\\float_placement " << float_placement << '\n';
404 os << "\\paperfontsize " << fontsize << '\n';
406 spacing.writeFile(os);
408 os << "\\papersize " << string_papersize[papersize2]
409 << "\n\\paperpackage " << string_paperpackages[paperpackage]
410 << "\n\\use_geometry " << use_geometry
411 << "\n\\use_amsmath " << use_amsmath
412 << "\n\\use_natbib " << use_natbib
413 << "\n\\use_numerical_citations " << use_numerical_citations
414 << "\n\\paperorientation " << string_orientation[orientation]
417 std::list<Branch>::const_iterator it = branchlist.begin();
418 std::list<Branch>::const_iterator end = branchlist.end();
419 for (; it != end; ++it) {
420 os << "\\branch " << it->getBranch()
421 << "\n\\selected " << it->getSelected()
422 << "\n\\color " << it->getColor()
427 if (!paperwidth.empty())
428 os << "\\paperwidth "
429 << VSpace(paperwidth).asLyXCommand() << '\n';
430 if (!paperheight.empty())
431 os << "\\paperheight "
432 << VSpace(paperheight).asLyXCommand() << '\n';
433 if (!leftmargin.empty())
434 os << "\\leftmargin "
435 << VSpace(leftmargin).asLyXCommand() << '\n';
436 if (!topmargin.empty())
438 << VSpace(topmargin).asLyXCommand() << '\n';
439 if (!rightmargin.empty())
440 os << "\\rightmargin "
441 << VSpace(rightmargin).asLyXCommand() << '\n';
442 if (!bottommargin.empty())
443 os << "\\bottommargin "
444 << VSpace(bottommargin).asLyXCommand() << '\n';
445 if (!headheight.empty())
446 os << "\\headheight "
447 << VSpace(headheight).asLyXCommand() << '\n';
448 if (!headsep.empty())
450 << VSpace(headsep).asLyXCommand() << '\n';
451 if (!footskip.empty())
453 << VSpace(footskip).asLyXCommand() << '\n';
454 os << "\\secnumdepth " << secnumdepth
455 << "\n\\tocdepth " << tocdepth
456 << "\n\\paragraph_separation "
457 << string_paragraph_separation[paragraph_separation]
458 << "\n\\defskip " << defskip.asLyXCommand()
459 << "\n\\quotes_language "
460 << string_quotes_language[quotes_language] << '\n';
461 switch (quotes_times) {
462 // An output operator for insetquotes would be nice
463 case InsetQuotes::SingleQ:
464 os << "\\quotes_times 1\n"; break;
465 case InsetQuotes::DoubleQ:
466 os << "\\quotes_times 2\n"; break;
468 os << "\\papercolumns " << columns
469 << "\n\\papersides " << sides
470 << "\n\\paperpagestyle " << pagestyle << '\n';
471 for (int i = 0; i < 4; ++i) {
472 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
473 if (user_defined_bullets[i].getFont() != -1) {
474 os << "\\bullet " << i
476 << user_defined_bullets[i].getFont()
478 << user_defined_bullets[i].getCharacter()
480 << user_defined_bullets[i].getSize()
481 << "\n\\end_bullet\n";
484 os << "\\bulletLaTeX " << i
486 << user_defined_bullets[i].getText()
487 << "\"\n\\end_bullet\n";
492 os << "\\tracking_changes " << tracking_changes << "\n";
494 if (tracking_changes) {
495 AuthorList::Authors::const_iterator it = authorlist.begin();
496 AuthorList::Authors::const_iterator end = authorlist.end();
497 for (; it != end; ++it) {
498 os << "\\author " << it->second << "\n";
504 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
505 TexRow & texrow) const
507 os << "\\documentclass";
509 LyXTextClass const & tclass = getLyXTextClass();
511 ostringstream clsoptions; // the document class options.
513 if (tokenPos(tclass.opt_fontsize(),
514 '|', fontsize) >= 0) {
515 // only write if existing in list (and not default)
516 clsoptions << fontsize << "pt,";
521 (paperpackage == PACKAGE_NONE)) {
524 clsoptions << "a3paper,";
527 clsoptions << "a4paper,";
530 clsoptions << "letterpaper,";
533 clsoptions << "a5paper,";
536 clsoptions << "b5paper,";
538 case PAPER_EXECUTIVEPAPER:
539 clsoptions << "executivepaper,";
541 case PAPER_LEGALPAPER:
542 clsoptions << "legalpaper,";
550 if (sides != tclass.sides()) {
552 case LyXTextClass::OneSide:
553 clsoptions << "oneside,";
555 case LyXTextClass::TwoSides:
556 clsoptions << "twoside,";
562 if (columns != tclass.columns()) {
564 clsoptions << "twocolumn,";
566 clsoptions << "onecolumn,";
570 && orientation == ORIENTATION_LANDSCAPE)
571 clsoptions << "landscape,";
573 // language should be a parameter to \documentclass
574 if (language->babel() == "hebrew"
575 && default_language->babel() != "hebrew")
576 // This seems necessary
577 features.useLanguage(default_language);
579 ostringstream language_options;
580 bool const use_babel = features.useBabel();
582 language_options << features.getLanguages();
583 language_options << language->babel();
584 if (lyxrc.language_global_options)
585 clsoptions << language_options.str() << ',';
588 // the user-defined options
589 if (!options.empty()) {
590 clsoptions << options << ',';
593 string strOptions(STRCONV(clsoptions.str()));
594 if (!strOptions.empty()) {
595 strOptions = rtrim(strOptions, ",");
596 os << '[' << strOptions << ']';
599 os << '{' << tclass.latexname() << "}\n";
601 // end of \documentclass defs
603 // font selection must be done before loading fontenc.sty
604 // The ae package is not needed when using OT1 font encoding.
605 if (fonts != "default" &&
606 (fonts != "ae" || lyxrc.fontenc != "default")) {
607 os << "\\usepackage{" << fonts << "}\n";
610 os << "\\usepackage{aecompl}\n";
614 // this one is not per buffer
615 if (lyxrc.fontenc != "default") {
616 os << "\\usepackage[" << lyxrc.fontenc
621 if (inputenc == "auto") {
622 string const doc_encoding =
623 language->encoding()->LatexName();
625 // Create a list with all the input encodings used
627 std::set<string> encodings =
628 features.getEncodingSet(doc_encoding);
630 os << "\\usepackage[";
631 std::copy(encodings.begin(), encodings.end(),
632 std::ostream_iterator<string>(os, ","));
633 os << doc_encoding << "]{inputenc}\n";
635 } else if (inputenc != "default") {
636 os << "\\usepackage[" << inputenc
641 // At the very beginning the text parameters.
642 if (paperpackage != PACKAGE_NONE) {
643 switch (paperpackage) {
647 os << "\\usepackage{a4}\n";
651 os << "\\usepackage{a4wide}\n";
654 case PACKAGE_WIDEMARGINSA4:
655 os << "\\usepackage[widemargins]{a4}\n";
661 os << "\\usepackage{geometry}\n";
663 os << "\\geometry{verbose";
664 if (orientation == ORIENTATION_LANDSCAPE)
666 switch (papersize2) {
667 case VM_PAPER_CUSTOM:
668 if (!paperwidth.empty())
671 if (!paperheight.empty())
672 os << ",paperheight="
675 case VM_PAPER_USLETTER:
676 os << ",letterpaper";
678 case VM_PAPER_USLEGAL:
681 case VM_PAPER_USEXECUTIVE:
682 os << ",executivepaper";
703 // default papersize ie VM_PAPER_DEFAULT
704 switch (lyxrc.default_papersize) {
705 case PAPER_DEFAULT: // keep compiler happy
707 os << ",letterpaper";
709 case PAPER_LEGALPAPER:
712 case PAPER_EXECUTIVEPAPER:
713 os << ",executivepaper";
729 if (!topmargin.empty())
730 os << ",tmargin=" << topmargin;
731 if (!bottommargin.empty())
732 os << ",bmargin=" << bottommargin;
733 if (!leftmargin.empty())
734 os << ",lmargin=" << leftmargin;
735 if (!rightmargin.empty())
736 os << ",rmargin=" << rightmargin;
737 if (!headheight.empty())
738 os << ",headheight=" << headheight;
739 if (!headsep.empty())
740 os << ",headsep=" << headsep;
741 if (!footskip.empty())
742 os << ",footskip=" << footskip;
747 if (tokenPos(tclass.opt_pagestyle(),
748 '|', pagestyle) >= 0) {
749 if (pagestyle == "fancy") {
750 os << "\\usepackage{fancyhdr}\n";
753 os << "\\pagestyle{" << pagestyle << "}\n";
757 if (secnumdepth != tclass.secnumdepth()) {
758 os << "\\setcounter{secnumdepth}{"
763 if (tocdepth != tclass.tocdepth()) {
764 os << "\\setcounter{tocdepth}{"
770 if (paragraph_separation) {
771 switch (defskip.kind()) {
772 case VSpace::SMALLSKIP:
773 os << "\\setlength\\parskip{\\smallskipamount}\n";
775 case VSpace::MEDSKIP:
776 os << "\\setlength\\parskip{\\medskipamount}\n";
778 case VSpace::BIGSKIP:
779 os << "\\setlength\\parskip{\\bigskipamount}\n";
782 os << "\\setlength\\parskip{"
783 << defskip.length().asLatexString()
786 default: // should never happen // Then delete it.
787 os << "\\setlength\\parskip{\\medskipamount}\n";
792 os << "\\setlength\\parindent{0pt}\n";
796 // Now insert the LyX specific LaTeX commands...
798 // The optional packages;
799 string lyxpreamble(features.getPackages());
801 // this might be useful...
802 lyxpreamble += "\n\\makeatletter\n";
804 // Some macros LyX will need
805 string tmppreamble(features.getMacros());
807 if (!tmppreamble.empty()) {
808 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
809 "LyX specific LaTeX commands.\n"
810 + tmppreamble + '\n';
813 // the text class specific preamble
814 tmppreamble = features.getTClassPreamble();
815 if (!tmppreamble.empty()) {
816 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
817 "Textclass specific LaTeX commands.\n"
818 + tmppreamble + '\n';
821 /* the user-defined preamble */
822 if (!preamble.empty()) {
823 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
824 "User specified LaTeX commands.\n"
828 // Itemize bullet settings need to be last in case the user
829 // defines their own bullets that use a package included
830 // in the user-defined preamble -- ARRae
831 // Actually it has to be done much later than that
832 // since some packages like frenchb make modifications
833 // at \begin{document} time -- JMarc
835 for (int i = 0; i < 4; ++i) {
836 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
837 if (bullets_def.empty())
838 bullets_def="\\AtBeginDocument{\n";
839 bullets_def += " \\renewcommand{\\labelitemi";
841 // `i' is one less than the item to modify
854 bullets_def += "}{" +
855 user_defined_bullets[i].getText()
860 if (!bullets_def.empty())
861 lyxpreamble += bullets_def + "}\n\n";
863 // We try to load babel late, in case it interferes
864 // with other packages.
866 string tmp = lyxrc.language_package;
867 if (!lyxrc.language_global_options
868 && tmp == "\\usepackage{babel}")
869 tmp = string("\\usepackage[") +
870 STRCONV(language_options.str()) +
872 lyxpreamble += tmp + "\n";
873 lyxpreamble += features.getBabelOptions();
876 lyxpreamble += "\\makeatother\n";
878 // dvipost settings come after everything else
879 if (tracking_changes) {
882 "\\dvipost{osstart color push Red}\n"
883 "\\dvipost{osend color pop}\n"
884 "\\dvipost{cbstart color push Blue}\n"
885 "\\dvipost{cbend color pop} \n";
889 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
890 for (int j = 0; j != nlines; ++j) {
898 void BufferParams::setPaperStuff()
900 papersize = PAPER_DEFAULT;
901 char const c1 = paperpackage;
902 if (c1 == PACKAGE_NONE) {
903 char const c2 = papersize2;
904 if (c2 == VM_PAPER_USLETTER)
905 papersize = PAPER_USLETTER;
906 else if (c2 == VM_PAPER_USLEGAL)
907 papersize = PAPER_LEGALPAPER;
908 else if (c2 == VM_PAPER_USEXECUTIVE)
909 papersize = PAPER_EXECUTIVEPAPER;
910 else if (c2 == VM_PAPER_A3)
911 papersize = PAPER_A3PAPER;
912 else if (c2 == VM_PAPER_A4)
913 papersize = PAPER_A4PAPER;
914 else if (c2 == VM_PAPER_A5)
915 papersize = PAPER_A5PAPER;
916 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
918 papersize = PAPER_B5PAPER;
919 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
920 (c1 == PACKAGE_WIDEMARGINSA4))
921 papersize = PAPER_A4PAPER;
925 void BufferParams::useClassDefaults()
927 LyXTextClass const & tclass = textclasslist[textclass];
929 sides = tclass.sides();
930 columns = tclass.columns();
931 pagestyle = tclass.pagestyle();
932 options = tclass.options();
933 secnumdepth = tclass.secnumdepth();
934 tocdepth = tclass.tocdepth();
938 bool BufferParams::hasClassDefaults() const
940 LyXTextClass const & tclass = textclasslist[textclass];
942 return (sides == tclass.sides()
943 && columns == tclass.columns()
944 && pagestyle == tclass.pagestyle()
945 && options == tclass.options()
946 && secnumdepth == tclass.secnumdepth()
947 && tocdepth == tclass.tocdepth());
951 LyXTextClass const & BufferParams::getLyXTextClass() const
953 return textclasslist[textclass];
957 void BufferParams::readPreamble(LyXLex & lex)
959 if (lex.getString() != "\\begin_preamble")
960 lyxerr << "Error (BufferParams::readPreamble):"
961 "consistency check failed." << endl;
963 preamble = lex.getLongString("\\end_preamble");
967 void BufferParams::readLanguage(LyXLex & lex)
969 if (!lex.next()) return;
971 string const tmptok = lex.getString();
973 // check if tmptok is part of tex_babel in tex-defs.h
974 language = languages.getLanguage(tmptok);
976 // Language tmptok was not found
977 language = default_language;
978 lyxerr << "Warning: Setting language `"
979 << tmptok << "' to `" << language->lang()
985 void BufferParams::readGraphicsDriver(LyXLex & lex)
987 if (!lex.next()) return;
989 string const tmptok = lex.getString();
990 // check if tmptok is part of tex_graphics in tex_defs.h
993 string const test = tex_graphics[n++];
995 if (test == tmptok) {
996 graphicsDriver = tmptok;
998 } else if (test == "last_item") {
1000 "Warning: graphics driver `$$Token' not recognized!\n"
1001 " Setting graphics driver to `default'.\n");
1002 graphicsDriver = "default";
1009 string const BufferParams::paperSizeName() const
1011 char real_papersize = papersize;
1012 if (real_papersize == PAPER_DEFAULT)
1013 real_papersize = lyxrc.default_papersize;
1015 switch (real_papersize) {
1024 case PAPER_EXECUTIVEPAPER:
1026 case PAPER_LEGALPAPER:
1028 case PAPER_USLETTER:
1035 string const BufferParams::dvips_options() const
1040 && papersize2 == VM_PAPER_CUSTOM
1041 && !lyxrc.print_paper_dimension_flag.empty()
1042 && !paperwidth.empty()
1043 && !paperheight.empty()) {
1044 // using a custom papersize
1045 result = lyxrc.print_paper_dimension_flag;
1046 result += ' ' + paperwidth;
1047 result += ',' + paperheight;
1049 string const paper_option = paperSizeName();
1050 if (paper_option != "letter" ||
1051 orientation != ORIENTATION_LANDSCAPE) {
1052 // dvips won't accept -t letter -t landscape.
1053 // In all other cases, include the paper size
1055 result = lyxrc.print_paper_flag;
1056 result += ' ' + paper_option;
1059 if (orientation == ORIENTATION_LANDSCAPE &&
1060 papersize2 != VM_PAPER_CUSTOM)
1061 result += ' ' + lyxrc.print_landscape_flag;