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;
37 using std::istringstream;
39 using std::ostringstream;
44 BufferParams::BufferParams()
45 // Initialize textclass to point to article. if `first' is
46 // true in the returned pair, then `second' is the textclass
47 // number; if it is false, second is 0. In both cases, second
49 : textclass(textclasslist.NumberOfClass("article").second)
51 paragraph_separation = PARSEP_INDENT;
52 defskip = VSpace(VSpace::MEDSKIP);
53 quotes_language = InsetQuotes::EnglishQ;
54 quotes_times = InsetQuotes::DoubleQ;
58 papersize = PAPER_DEFAULT;
59 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
60 paperpackage = PACKAGE_NONE;
61 orientation = ORIENTATION_PORTRAIT;
63 use_amsmath = AMS_AUTO;
65 use_numerical_citations = false;
66 tracking_changes = false;
69 language = default_language;
72 graphicsDriver = "default";
73 sides = LyXTextClass::OneSide;
75 pagestyle = "default";
77 for (int iter = 0; iter < 4; ++iter) {
78 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
79 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
84 string const BufferParams::readToken(LyXLex & lex, string const & token)
86 if (token == "\\textclass") {
88 string const classname = lex.getString();
89 pair<bool, lyx::textclass_type> pp =
90 textclasslist.NumberOfClass(classname);
92 textclass = pp.second;
97 if (!getLyXTextClass().isTeXClassAvailable()) {
98 string msg = bformat(_("The document uses a missing "
99 "TeX class \"%1$s\".\n"), classname);
100 Alert::warning(_("Document class not available"),
101 msg + _("LyX will not be able to produce output."));
103 } else if (token == "\\begin_preamble") {
105 } else if (token == "\\options") {
107 options = lex.getString();
108 } else if (token == "\\language") {
110 } else if (token == "\\inputencoding") {
112 inputenc = lex.getString();
113 } else if (token == "\\graphics") {
114 readGraphicsDriver(lex);
115 } else if (token == "\\fontscheme") {
117 fonts = lex.getString();
118 } else if (token == "\\paragraph_separation") {
119 int tmpret = lex.findToken(string_paragraph_separation);
122 paragraph_separation =
123 static_cast<PARSEP>(tmpret);
124 } else if (token == "\\defskip") {
126 defskip = VSpace(lex.getString());
127 } else if (token == "\\quotes_language") {
128 // FIXME: should be params.readQuotes()
129 int tmpret = lex.findToken(string_quotes_language);
132 InsetQuotes::quote_language tmpl =
133 InsetQuotes::EnglishQ;
136 tmpl = InsetQuotes::EnglishQ;
139 tmpl = InsetQuotes::SwedishQ;
142 tmpl = InsetQuotes::GermanQ;
145 tmpl = InsetQuotes::PolishQ;
148 tmpl = InsetQuotes::FrenchQ;
151 tmpl = InsetQuotes::DanishQ;
154 quotes_language = tmpl;
155 } else if (token == "\\quotes_times") {
156 // FIXME: should be params.readQuotes()
158 switch (lex.getInteger()) {
160 quotes_times = InsetQuotes::SingleQ;
163 quotes_times = InsetQuotes::DoubleQ;
166 } else if (token == "\\papersize") {
167 int tmpret = lex.findToken(string_papersize);
171 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
172 } else if (token == "\\paperpackage") {
173 int tmpret = lex.findToken(string_paperpackages);
176 paperpackage = PACKAGE_NONE;
178 paperpackage = PAPER_PACKAGES(tmpret);
179 } else if (token == "\\use_geometry") {
181 use_geometry = lex.getInteger();
182 } else if (token == "\\use_amsmath") {
184 use_amsmath = static_cast<AMS>(
186 } else if (token == "\\use_natbib") {
188 use_natbib = lex.getInteger();
189 } else if (token == "\\use_numerical_citations") {
191 use_numerical_citations = lex.getInteger();
192 } else if (token == "\\tracking_changes") {
194 tracking_changes = lex.getInteger();
195 } else if (token == "\\branch") {
197 string branch = lex.getString();
198 branchlist.add(branch);
201 string const tok = lex.getString();
202 if (tok == "\\end_branch")
204 if (tok == "\\selected") {
206 branchlist.setSelected(branch, lex.getInteger());
208 // not yet operational
209 if (tok == "\\color") {
211 string color = lex.getString();
212 branchlist.setColor(branch, color);
213 // Update also the LColor table:
215 color = lcolor.getX11Name(LColor::background);
216 lcolor.fill(static_cast<LColor::color>(lcolor.size()),
220 } else if (token == "\\author") {
222 istringstream ss(STRCONV(lex.getString()));
225 author_map.push_back(authorlist.record(a));
226 } else if (token == "\\paperorientation") {
227 int tmpret = lex.findToken(string_orientation);
231 static_cast<PAPER_ORIENTATION>(tmpret);
232 } else if (token == "\\paperwidth") {
234 paperwidth = lex.getString();
235 } else if (token == "\\paperheight") {
237 paperheight = lex.getString();
238 } else if (token == "\\leftmargin") {
240 leftmargin = lex.getString();
241 } else if (token == "\\topmargin") {
243 topmargin = lex.getString();
244 } else if (token == "\\rightmargin") {
246 rightmargin = lex.getString();
247 } else if (token == "\\bottommargin") {
249 bottommargin = lex.getString();
250 } else if (token == "\\headheight") {
252 headheight = lex.getString();
253 } else if (token == "\\headsep") {
255 headsep = lex.getString();
256 } else if (token == "\\footskip") {
258 footskip = lex.getString();
259 } else if (token == "\\paperfontsize") {
261 fontsize = rtrim(lex.getString());
262 } else if (token == "\\papercolumns") {
264 columns = lex.getInteger();
265 } else if (token == "\\papersides") {
267 switch (lex.getInteger()) {
269 case 1: sides = LyXTextClass::OneSide; break;
270 case 2: sides = LyXTextClass::TwoSides; break;
272 } else if (token == "\\paperpagestyle") {
274 pagestyle = rtrim(lex.getString());
275 } else if (token == "\\bullet") {
276 // FIXME: should be params.readBullets()
278 int const index = lex.getInteger();
280 int temp_int = lex.getInteger();
281 user_defined_bullets[index].setFont(temp_int);
282 temp_bullets[index].setFont(temp_int);
284 temp_int = lex.getInteger();
285 user_defined_bullets[index].setCharacter(temp_int);
286 temp_bullets[index].setCharacter(temp_int);
288 temp_int = lex.getInteger();
289 user_defined_bullets[index].setSize(temp_int);
290 temp_bullets[index].setSize(temp_int);
292 string const temp_str = lex.getString();
293 if (temp_str != "\\end_bullet") {
294 // this element isn't really necessary for
295 // parsing but is easier for humans
296 // to understand bullets. Put it back and
297 // set a debug message?
298 lex.printError("\\end_bullet expected, got" + temp_str);
299 //how can I put it back?
301 } else if (token == "\\bulletLaTeX") {
302 // The bullet class should be able to read this.
304 int const index = lex.getInteger();
306 string temp_str = lex.getString();
308 while (temp_str != "\\end_bullet") {
309 // this loop structure is needed when user
310 // enters an empty string since the first
311 // thing returned will be the \\end_bullet
313 // if the LaTeX entry has spaces. Each element
314 // therefore needs to be read in turn
317 temp_str = lex.getString();
320 user_defined_bullets[index].setText(sum_str);
321 temp_bullets[index].setText(sum_str);
322 } else if (token == "\\secnumdepth") {
324 secnumdepth = lex.getInteger();
325 } else if (token == "\\tocdepth") {
327 tocdepth = lex.getInteger();
328 } else if (token == "\\spacing") {
330 string const tmp = rtrim(lex.getString());
331 Spacing::Space tmp_space = Spacing::Default;
333 if (tmp == "single") {
334 tmp_space = Spacing::Single;
335 } else if (tmp == "onehalf") {
336 tmp_space = Spacing::Onehalf;
337 } else if (tmp == "double") {
338 tmp_space = Spacing::Double;
339 } else if (tmp == "other") {
341 tmp_space = Spacing::Other;
342 tmp_val = lex.getFloat();
344 lex.printError("Unknown spacing token: '$$Token'");
346 #if 0 // FIXME: Handled in lyx2lyx ?
347 // Small hack so that files written with klyx will be
350 par->params().spacing(Spacing(tmp_space, tmp_val));
352 spacing.set(tmp_space, tmp_val);
353 } else if (token == "\\float_placement") {
355 float_placement = lex.getString();
364 void BufferParams::writeFile(ostream & os) const
366 // The top of the file is written by the buffer.
367 // Prints out the buffer info into the .lyx file given by file
370 os << "\\textclass " << textclasslist[textclass].name() << '\n';
372 // then the the preamble
373 if (!preamble.empty()) {
374 // remove '\n' from the end of preamble
375 string const tmppreamble = rtrim(preamble, "\n");
376 os << "\\begin_preamble\n"
378 << "\n\\end_preamble\n";
382 if (!options.empty()) {
383 os << "\\options " << options << '\n';
386 /* then the text parameters */
387 if (language != ignore_language)
388 os << "\\language " << language->lang() << '\n';
389 os << "\\inputencoding " << inputenc
390 << "\n\\fontscheme " << fonts
391 << "\n\\graphics " << graphicsDriver << '\n';
393 if (!float_placement.empty()) {
394 os << "\\float_placement " << float_placement << '\n';
396 os << "\\paperfontsize " << fontsize << '\n';
398 spacing.writeFile(os);
400 os << "\\papersize " << string_papersize[papersize2]
401 << "\n\\paperpackage " << string_paperpackages[paperpackage]
402 << "\n\\use_geometry " << use_geometry
403 << "\n\\use_amsmath " << use_amsmath
404 << "\n\\use_natbib " << use_natbib
405 << "\n\\use_numerical_citations " << use_numerical_citations
406 << "\n\\paperorientation " << string_orientation[orientation]
409 std::list<Branch>::const_iterator it = branchlist.begin();
410 std::list<Branch>::const_iterator end = branchlist.end();
411 for (; it != end; ++it) {
412 os << "\\branch " << it->getBranch()
413 << "\n\\selected " << it->getSelected()
414 << "\n\\color " << it->getColor()
419 if (!paperwidth.empty())
420 os << "\\paperwidth "
421 << VSpace(paperwidth).asLyXCommand() << '\n';
422 if (!paperheight.empty())
423 os << "\\paperheight "
424 << VSpace(paperheight).asLyXCommand() << '\n';
425 if (!leftmargin.empty())
426 os << "\\leftmargin "
427 << VSpace(leftmargin).asLyXCommand() << '\n';
428 if (!topmargin.empty())
430 << VSpace(topmargin).asLyXCommand() << '\n';
431 if (!rightmargin.empty())
432 os << "\\rightmargin "
433 << VSpace(rightmargin).asLyXCommand() << '\n';
434 if (!bottommargin.empty())
435 os << "\\bottommargin "
436 << VSpace(bottommargin).asLyXCommand() << '\n';
437 if (!headheight.empty())
438 os << "\\headheight "
439 << VSpace(headheight).asLyXCommand() << '\n';
440 if (!headsep.empty())
442 << VSpace(headsep).asLyXCommand() << '\n';
443 if (!footskip.empty())
445 << VSpace(footskip).asLyXCommand() << '\n';
446 os << "\\secnumdepth " << secnumdepth
447 << "\n\\tocdepth " << tocdepth
448 << "\n\\paragraph_separation "
449 << string_paragraph_separation[paragraph_separation]
450 << "\n\\defskip " << defskip.asLyXCommand()
451 << "\n\\quotes_language "
452 << string_quotes_language[quotes_language] << '\n';
453 switch (quotes_times) {
454 // An output operator for insetquotes would be nice
455 case InsetQuotes::SingleQ:
456 os << "\\quotes_times 1\n"; break;
457 case InsetQuotes::DoubleQ:
458 os << "\\quotes_times 2\n"; break;
460 os << "\\papercolumns " << columns
461 << "\n\\papersides " << sides
462 << "\n\\paperpagestyle " << pagestyle << '\n';
463 for (int i = 0; i < 4; ++i) {
464 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
465 if (user_defined_bullets[i].getFont() != -1) {
466 os << "\\bullet " << i
468 << user_defined_bullets[i].getFont()
470 << user_defined_bullets[i].getCharacter()
472 << user_defined_bullets[i].getSize()
473 << "\n\\end_bullet\n";
476 os << "\\bulletLaTeX " << i
478 << user_defined_bullets[i].getText()
479 << "\"\n\\end_bullet\n";
484 os << "\\tracking_changes " << tracking_changes << "\n";
486 if (tracking_changes) {
487 AuthorList::Authors::const_iterator it = authorlist.begin();
488 AuthorList::Authors::const_iterator end = authorlist.end();
489 for (; it != end; ++it) {
490 os << "\\author " << it->second << "\n";
496 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
497 TexRow & texrow) const
499 os << "\\documentclass";
501 LyXTextClass const & tclass = getLyXTextClass();
503 ostringstream clsoptions; // the document class options.
505 if (tokenPos(tclass.opt_fontsize(),
506 '|', fontsize) >= 0) {
507 // only write if existing in list (and not default)
508 clsoptions << fontsize << "pt,";
513 (paperpackage == PACKAGE_NONE)) {
516 clsoptions << "a3paper,";
519 clsoptions << "a4paper,";
522 clsoptions << "letterpaper,";
525 clsoptions << "a5paper,";
528 clsoptions << "b5paper,";
530 case PAPER_EXECUTIVEPAPER:
531 clsoptions << "executivepaper,";
533 case PAPER_LEGALPAPER:
534 clsoptions << "legalpaper,";
542 if (sides != tclass.sides()) {
544 case LyXTextClass::OneSide:
545 clsoptions << "oneside,";
547 case LyXTextClass::TwoSides:
548 clsoptions << "twoside,";
554 if (columns != tclass.columns()) {
556 clsoptions << "twocolumn,";
558 clsoptions << "onecolumn,";
562 && orientation == ORIENTATION_LANDSCAPE)
563 clsoptions << "landscape,";
565 // language should be a parameter to \documentclass
566 if (language->babel() == "hebrew"
567 && default_language->babel() != "hebrew")
568 // This seems necessary
569 features.useLanguage(default_language);
571 ostringstream language_options;
572 bool const use_babel = features.useBabel();
574 language_options << features.getLanguages();
575 language_options << language->babel();
576 if (lyxrc.language_global_options)
577 clsoptions << language_options.str() << ',';
580 // the user-defined options
581 if (!options.empty()) {
582 clsoptions << options << ',';
585 string strOptions(STRCONV(clsoptions.str()));
586 if (!strOptions.empty()) {
587 strOptions = rtrim(strOptions, ",");
588 os << '[' << strOptions << ']';
591 os << '{' << tclass.latexname() << "}\n";
593 // end of \documentclass defs
595 // font selection must be done before loading fontenc.sty
596 // The ae package is not needed when using OT1 font encoding.
597 if (fonts != "default" &&
598 (fonts != "ae" || lyxrc.fontenc != "default")) {
599 os << "\\usepackage{" << fonts << "}\n";
602 os << "\\usepackage{aecompl}\n";
606 // this one is not per buffer
607 if (lyxrc.fontenc != "default") {
608 os << "\\usepackage[" << lyxrc.fontenc
613 if (inputenc == "auto") {
614 string const doc_encoding =
615 language->encoding()->LatexName();
617 // Create a list with all the input encodings used
619 std::set<string> encodings =
620 features.getEncodingSet(doc_encoding);
622 os << "\\usepackage[";
623 std::copy(encodings.begin(), encodings.end(),
624 std::ostream_iterator<string>(os, ","));
625 os << doc_encoding << "]{inputenc}\n";
627 } else if (inputenc != "default") {
628 os << "\\usepackage[" << inputenc
633 // At the very beginning the text parameters.
634 if (paperpackage != PACKAGE_NONE) {
635 switch (paperpackage) {
639 os << "\\usepackage{a4}\n";
643 os << "\\usepackage{a4wide}\n";
646 case PACKAGE_WIDEMARGINSA4:
647 os << "\\usepackage[widemargins]{a4}\n";
653 os << "\\usepackage{geometry}\n";
655 os << "\\geometry{verbose";
656 if (orientation == ORIENTATION_LANDSCAPE)
658 switch (papersize2) {
659 case VM_PAPER_CUSTOM:
660 if (!paperwidth.empty())
663 if (!paperheight.empty())
664 os << ",paperheight="
667 case VM_PAPER_USLETTER:
668 os << ",letterpaper";
670 case VM_PAPER_USLEGAL:
673 case VM_PAPER_USEXECUTIVE:
674 os << ",executivepaper";
695 // default papersize ie VM_PAPER_DEFAULT
696 switch (lyxrc.default_papersize) {
697 case PAPER_DEFAULT: // keep compiler happy
699 os << ",letterpaper";
701 case PAPER_LEGALPAPER:
704 case PAPER_EXECUTIVEPAPER:
705 os << ",executivepaper";
721 if (!topmargin.empty())
722 os << ",tmargin=" << topmargin;
723 if (!bottommargin.empty())
724 os << ",bmargin=" << bottommargin;
725 if (!leftmargin.empty())
726 os << ",lmargin=" << leftmargin;
727 if (!rightmargin.empty())
728 os << ",rmargin=" << rightmargin;
729 if (!headheight.empty())
730 os << ",headheight=" << headheight;
731 if (!headsep.empty())
732 os << ",headsep=" << headsep;
733 if (!footskip.empty())
734 os << ",footskip=" << footskip;
739 if (tokenPos(tclass.opt_pagestyle(),
740 '|', pagestyle) >= 0) {
741 if (pagestyle == "fancy") {
742 os << "\\usepackage{fancyhdr}\n";
745 os << "\\pagestyle{" << pagestyle << "}\n";
749 if (secnumdepth != tclass.secnumdepth()) {
750 os << "\\setcounter{secnumdepth}{"
755 if (tocdepth != tclass.tocdepth()) {
756 os << "\\setcounter{tocdepth}{"
762 if (paragraph_separation) {
763 switch (defskip.kind()) {
764 case VSpace::SMALLSKIP:
765 os << "\\setlength\\parskip{\\smallskipamount}\n";
767 case VSpace::MEDSKIP:
768 os << "\\setlength\\parskip{\\medskipamount}\n";
770 case VSpace::BIGSKIP:
771 os << "\\setlength\\parskip{\\bigskipamount}\n";
774 os << "\\setlength\\parskip{"
775 << defskip.length().asLatexString()
778 default: // should never happen // Then delete it.
779 os << "\\setlength\\parskip{\\medskipamount}\n";
784 os << "\\setlength\\parindent{0pt}\n";
788 // Now insert the LyX specific LaTeX commands...
790 // The optional packages;
791 string lyxpreamble(features.getPackages());
793 // this might be useful...
794 lyxpreamble += "\n\\makeatletter\n";
796 // Some macros LyX will need
797 string tmppreamble(features.getMacros());
799 if (!tmppreamble.empty()) {
800 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
801 "LyX specific LaTeX commands.\n"
802 + tmppreamble + '\n';
805 // the text class specific preamble
806 tmppreamble = features.getTClassPreamble();
807 if (!tmppreamble.empty()) {
808 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
809 "Textclass specific LaTeX commands.\n"
810 + tmppreamble + '\n';
813 /* the user-defined preamble */
814 if (!preamble.empty()) {
815 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
816 "User specified LaTeX commands.\n"
820 // Itemize bullet settings need to be last in case the user
821 // defines their own bullets that use a package included
822 // in the user-defined preamble -- ARRae
823 // Actually it has to be done much later than that
824 // since some packages like frenchb make modifications
825 // at \begin{document} time -- JMarc
827 for (int i = 0; i < 4; ++i) {
828 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
829 if (bullets_def.empty())
830 bullets_def="\\AtBeginDocument{\n";
831 bullets_def += " \\renewcommand{\\labelitemi";
833 // `i' is one less than the item to modify
846 bullets_def += "}{" +
847 user_defined_bullets[i].getText()
852 if (!bullets_def.empty())
853 lyxpreamble += bullets_def + "}\n\n";
855 // We try to load babel late, in case it interferes
856 // with other packages.
858 string tmp = lyxrc.language_package;
859 if (!lyxrc.language_global_options
860 && tmp == "\\usepackage{babel}")
861 tmp = string("\\usepackage[") +
862 STRCONV(language_options.str()) +
864 lyxpreamble += tmp + "\n";
865 lyxpreamble += features.getBabelOptions();
868 lyxpreamble += "\\makeatother\n";
870 // dvipost settings come after everything else
871 if (tracking_changes) {
874 "\\dvipost{osstart color push Red}\n"
875 "\\dvipost{osend color pop}\n"
876 "\\dvipost{cbstart color push Blue}\n"
877 "\\dvipost{cbend color pop} \n";
881 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
882 for (int j = 0; j != nlines; ++j) {
890 void BufferParams::setPaperStuff()
892 papersize = PAPER_DEFAULT;
893 char const c1 = paperpackage;
894 if (c1 == PACKAGE_NONE) {
895 char const c2 = papersize2;
896 if (c2 == VM_PAPER_USLETTER)
897 papersize = PAPER_USLETTER;
898 else if (c2 == VM_PAPER_USLEGAL)
899 papersize = PAPER_LEGALPAPER;
900 else if (c2 == VM_PAPER_USEXECUTIVE)
901 papersize = PAPER_EXECUTIVEPAPER;
902 else if (c2 == VM_PAPER_A3)
903 papersize = PAPER_A3PAPER;
904 else if (c2 == VM_PAPER_A4)
905 papersize = PAPER_A4PAPER;
906 else if (c2 == VM_PAPER_A5)
907 papersize = PAPER_A5PAPER;
908 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
910 papersize = PAPER_B5PAPER;
911 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
912 (c1 == PACKAGE_WIDEMARGINSA4))
913 papersize = PAPER_A4PAPER;
917 void BufferParams::useClassDefaults()
919 LyXTextClass const & tclass = textclasslist[textclass];
921 sides = tclass.sides();
922 columns = tclass.columns();
923 pagestyle = tclass.pagestyle();
924 options = tclass.options();
925 secnumdepth = tclass.secnumdepth();
926 tocdepth = tclass.tocdepth();
930 bool BufferParams::hasClassDefaults() const
932 LyXTextClass const & tclass = textclasslist[textclass];
934 return (sides == tclass.sides()
935 && columns == tclass.columns()
936 && pagestyle == tclass.pagestyle()
937 && options == tclass.options()
938 && secnumdepth == tclass.secnumdepth()
939 && tocdepth == tclass.tocdepth());
943 LyXTextClass const & BufferParams::getLyXTextClass() const
945 return textclasslist[textclass];
949 void BufferParams::readPreamble(LyXLex & lex)
951 if (lex.getString() != "\\begin_preamble")
952 lyxerr << "Error (BufferParams::readPreamble):"
953 "consistency check failed." << endl;
955 preamble = lex.getLongString("\\end_preamble");
959 void BufferParams::readLanguage(LyXLex & lex)
961 if (!lex.next()) return;
963 string const tmptok = lex.getString();
965 // check if tmptok is part of tex_babel in tex-defs.h
966 language = languages.getLanguage(tmptok);
968 // Language tmptok was not found
969 language = default_language;
970 lyxerr << "Warning: Setting language `"
971 << tmptok << "' to `" << language->lang()
977 void BufferParams::readGraphicsDriver(LyXLex & lex)
979 if (!lex.next()) return;
981 string const tmptok = lex.getString();
982 // check if tmptok is part of tex_graphics in tex_defs.h
985 string const test = tex_graphics[n++];
987 if (test == tmptok) {
988 graphicsDriver = tmptok;
990 } else if (test == "last_item") {
992 "Warning: graphics driver `$$Token' not recognized!\n"
993 " Setting graphics driver to `default'.\n");
994 graphicsDriver = "default";
1001 string const BufferParams::paperSizeName() const
1003 char real_papersize = papersize;
1004 if (real_papersize == PAPER_DEFAULT)
1005 real_papersize = lyxrc.default_papersize;
1007 switch (real_papersize) {
1016 case PAPER_EXECUTIVEPAPER:
1018 case PAPER_LEGALPAPER:
1020 case PAPER_USLETTER:
1027 string const BufferParams::dvips_options() const
1032 && papersize2 == VM_PAPER_CUSTOM
1033 && !lyxrc.print_paper_dimension_flag.empty()
1034 && !paperwidth.empty()
1035 && !paperheight.empty()) {
1036 // using a custom papersize
1037 result = lyxrc.print_paper_dimension_flag;
1038 result += ' ' + paperwidth;
1039 result += ',' + paperheight;
1041 string const paper_option = paperSizeName();
1042 if (paper_option != "letter" ||
1043 orientation != ORIENTATION_LANDSCAPE) {
1044 // dvips won't accept -t letter -t landscape.
1045 // In all other cases, include the paper size
1047 result = lyxrc.print_paper_flag;
1048 result += ' ' + paper_option;
1051 if (orientation == ORIENTATION_LANDSCAPE &&
1052 papersize2 != VM_PAPER_CUSTOM)
1053 result += ' ' + lyxrc.print_landscape_flag;