1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
13 #include "bufferparams.h"
14 #include "tex-strings.h"
21 #include "lyxtextclasslist.h"
29 #include "support/lyxalgo.h" // for lyx::count
30 #include "support/lyxlib.h"
31 #include "support/lstrings.h"
32 #include "support/types.h"
34 #include "frontends/Alert.h"
39 using namespace lyx::support;
46 BufferParams::BufferParams()
47 // Initialize textclass to point to article. if `first' is
48 // true in the returned pair, then `second' is the textclass
49 // number; if it is false, second is 0. In both cases, second
51 : textclass(textclasslist.NumberOfClass("article").second)
53 paragraph_separation = PARSEP_INDENT;
54 defskip = VSpace(VSpace::MEDSKIP);
55 quotes_language = InsetQuotes::EnglishQ;
56 quotes_times = InsetQuotes::DoubleQ;
60 papersize = PAPER_DEFAULT;
61 papersize2 = VM_PAPER_DEFAULT; /* DEFAULT */
62 paperpackage = PACKAGE_NONE;
63 orientation = ORIENTATION_PORTRAIT;
65 use_amsmath = AMS_AUTO;
67 use_numerical_citations = false;
68 tracking_changes = false;
71 language = default_language;
74 graphicsDriver = "default";
75 sides = LyXTextClass::OneSide;
77 pagestyle = "default";
79 for (int iter = 0; iter < 4; ++iter) {
80 user_defined_bullets[iter] = ITEMIZE_DEFAULTS[iter];
81 temp_bullets[iter] = ITEMIZE_DEFAULTS[iter];
86 string const BufferParams::readToken(LyXLex & lex, string const & token)
88 if (token == "\\textclass") {
90 string const classname = lex.getString();
91 pair<bool, lyx::textclass_type> pp =
92 textclasslist.NumberOfClass(classname);
94 textclass = pp.second;
99 if (!getLyXTextClass().isTeXClassAvailable()) {
100 string msg = bformat(_("The document uses a missing "
101 "TeX class \"%1$s\".\n"), classname);
102 Alert::warning(_("Document class not available"),
103 msg + _("LyX will not be able to produce output."));
105 } else if (token == "\\begin_preamble") {
107 } else if (token == "\\options") {
109 options = lex.getString();
110 } else if (token == "\\language") {
112 } else if (token == "\\inputencoding") {
114 inputenc = lex.getString();
115 } else if (token == "\\graphics") {
116 readGraphicsDriver(lex);
117 } else if (token == "\\fontscheme") {
119 fonts = lex.getString();
120 } else if (token == "\\paragraph_separation") {
121 int tmpret = lex.findToken(string_paragraph_separation);
124 paragraph_separation =
125 static_cast<PARSEP>(tmpret);
126 } else if (token == "\\defskip") {
128 defskip = VSpace(lex.getString());
129 } else if (token == "\\quotes_language") {
130 // FIXME: should be params.readQuotes()
131 int tmpret = lex.findToken(string_quotes_language);
134 InsetQuotes::quote_language tmpl =
135 InsetQuotes::EnglishQ;
138 tmpl = InsetQuotes::EnglishQ;
141 tmpl = InsetQuotes::SwedishQ;
144 tmpl = InsetQuotes::GermanQ;
147 tmpl = InsetQuotes::PolishQ;
150 tmpl = InsetQuotes::FrenchQ;
153 tmpl = InsetQuotes::DanishQ;
156 quotes_language = tmpl;
157 } else if (token == "\\quotes_times") {
158 // FIXME: should be params.readQuotes()
160 switch (lex.getInteger()) {
162 quotes_times = InsetQuotes::SingleQ;
165 quotes_times = InsetQuotes::DoubleQ;
168 } else if (token == "\\papersize") {
169 int tmpret = lex.findToken(string_papersize);
173 papersize2 = VMARGIN_PAPER_TYPE(tmpret);
174 } else if (token == "\\paperpackage") {
175 int tmpret = lex.findToken(string_paperpackages);
178 paperpackage = PACKAGE_NONE;
180 paperpackage = PAPER_PACKAGES(tmpret);
181 } else if (token == "\\use_geometry") {
183 use_geometry = lex.getInteger();
184 } else if (token == "\\use_amsmath") {
186 use_amsmath = static_cast<AMS>(
188 } else if (token == "\\use_natbib") {
190 use_natbib = lex.getInteger();
191 } else if (token == "\\use_numerical_citations") {
193 use_numerical_citations = lex.getInteger();
194 } else if (token == "\\tracking_changes") {
196 tracking_changes = lex.getInteger();
197 } else if (token == "\\branch") {
199 string branch = lex.getString();
200 branchlist.add(branch);
203 string const tok = lex.getString();
204 if (tok == "\\end_branch")
206 if (tok == "\\selected") {
208 branchlist.setSelected(branch, lex.getInteger());
210 // not yet operational
211 if (tok == "\\color") {
213 string color = lex.getString();
214 branchlist.setColor(branch, color);
215 // Update also the LColor table:
217 color = lcolor.getX11Name(LColor::background);
218 lcolor.fill(static_cast<LColor::color>(lcolor.size()),
222 } else if (token == "\\author") {
224 istringstream ss(STRCONV(lex.getString()));
227 author_map.push_back(authorlist.record(a));
228 } else if (token == "\\paperorientation") {
229 int tmpret = lex.findToken(string_orientation);
233 static_cast<PAPER_ORIENTATION>(tmpret);
234 } else if (token == "\\paperwidth") {
236 paperwidth = lex.getString();
237 } else if (token == "\\paperheight") {
239 paperheight = lex.getString();
240 } else if (token == "\\leftmargin") {
242 leftmargin = lex.getString();
243 } else if (token == "\\topmargin") {
245 topmargin = lex.getString();
246 } else if (token == "\\rightmargin") {
248 rightmargin = lex.getString();
249 } else if (token == "\\bottommargin") {
251 bottommargin = lex.getString();
252 } else if (token == "\\headheight") {
254 headheight = lex.getString();
255 } else if (token == "\\headsep") {
257 headsep = lex.getString();
258 } else if (token == "\\footskip") {
260 footskip = lex.getString();
261 } else if (token == "\\paperfontsize") {
263 fontsize = rtrim(lex.getString());
264 } else if (token == "\\papercolumns") {
266 columns = lex.getInteger();
267 } else if (token == "\\papersides") {
269 switch (lex.getInteger()) {
271 case 1: sides = LyXTextClass::OneSide; break;
272 case 2: sides = LyXTextClass::TwoSides; break;
274 } else if (token == "\\paperpagestyle") {
276 pagestyle = rtrim(lex.getString());
277 } else if (token == "\\bullet") {
278 // FIXME: should be params.readBullets()
280 int const index = lex.getInteger();
282 int temp_int = lex.getInteger();
283 user_defined_bullets[index].setFont(temp_int);
284 temp_bullets[index].setFont(temp_int);
286 temp_int = lex.getInteger();
287 user_defined_bullets[index].setCharacter(temp_int);
288 temp_bullets[index].setCharacter(temp_int);
290 temp_int = lex.getInteger();
291 user_defined_bullets[index].setSize(temp_int);
292 temp_bullets[index].setSize(temp_int);
294 string const temp_str = lex.getString();
295 if (temp_str != "\\end_bullet") {
296 // this element isn't really necessary for
297 // parsing but is easier for humans
298 // to understand bullets. Put it back and
299 // set a debug message?
300 lex.printError("\\end_bullet expected, got" + temp_str);
301 //how can I put it back?
303 } else if (token == "\\bulletLaTeX") {
304 // The bullet class should be able to read this.
306 int const index = lex.getInteger();
308 string temp_str = lex.getString();
310 while (temp_str != "\\end_bullet") {
311 // this loop structure is needed when user
312 // enters an empty string since the first
313 // thing returned will be the \\end_bullet
315 // if the LaTeX entry has spaces. Each element
316 // therefore needs to be read in turn
319 temp_str = lex.getString();
322 user_defined_bullets[index].setText(sum_str);
323 temp_bullets[index].setText(sum_str);
324 } else if (token == "\\secnumdepth") {
326 secnumdepth = lex.getInteger();
327 } else if (token == "\\tocdepth") {
329 tocdepth = lex.getInteger();
330 } else if (token == "\\spacing") {
332 string const tmp = rtrim(lex.getString());
333 Spacing::Space tmp_space = Spacing::Default;
335 if (tmp == "single") {
336 tmp_space = Spacing::Single;
337 } else if (tmp == "onehalf") {
338 tmp_space = Spacing::Onehalf;
339 } else if (tmp == "double") {
340 tmp_space = Spacing::Double;
341 } else if (tmp == "other") {
343 tmp_space = Spacing::Other;
344 tmp_val = lex.getFloat();
346 lex.printError("Unknown spacing token: '$$Token'");
348 #if 0 // FIXME: Handled in lyx2lyx ?
349 // Small hack so that files written with klyx will be
352 par->params().spacing(Spacing(tmp_space, tmp_val));
354 spacing.set(tmp_space, tmp_val);
355 } else if (token == "\\float_placement") {
357 float_placement = lex.getString();
366 void BufferParams::writeFile(ostream & os) const
368 // The top of the file is written by the buffer.
369 // Prints out the buffer info into the .lyx file given by file
372 os << "\\textclass " << textclasslist[textclass].name() << '\n';
374 // then the the preamble
375 if (!preamble.empty()) {
376 // remove '\n' from the end of preamble
377 string const tmppreamble = rtrim(preamble, "\n");
378 os << "\\begin_preamble\n"
380 << "\n\\end_preamble\n";
384 if (!options.empty()) {
385 os << "\\options " << options << '\n';
388 /* then the text parameters */
389 if (language != ignore_language)
390 os << "\\language " << language->lang() << '\n';
391 os << "\\inputencoding " << inputenc
392 << "\n\\fontscheme " << fonts
393 << "\n\\graphics " << graphicsDriver << '\n';
395 if (!float_placement.empty()) {
396 os << "\\float_placement " << float_placement << '\n';
398 os << "\\paperfontsize " << fontsize << '\n';
400 spacing.writeFile(os);
402 os << "\\papersize " << string_papersize[papersize2]
403 << "\n\\paperpackage " << string_paperpackages[paperpackage]
404 << "\n\\use_geometry " << use_geometry
405 << "\n\\use_amsmath " << use_amsmath
406 << "\n\\use_natbib " << use_natbib
407 << "\n\\use_numerical_citations " << use_numerical_citations
408 << "\n\\paperorientation " << string_orientation[orientation]
411 std::list<Branch>::const_iterator it = branchlist.begin();
412 std::list<Branch>::const_iterator end = branchlist.end();
413 for (; it != end; ++it) {
414 os << "\\branch " << it->getBranch()
415 << "\n\\selected " << it->getSelected()
416 << "\n\\color " << it->getColor()
421 if (!paperwidth.empty())
422 os << "\\paperwidth "
423 << VSpace(paperwidth).asLyXCommand() << '\n';
424 if (!paperheight.empty())
425 os << "\\paperheight "
426 << VSpace(paperheight).asLyXCommand() << '\n';
427 if (!leftmargin.empty())
428 os << "\\leftmargin "
429 << VSpace(leftmargin).asLyXCommand() << '\n';
430 if (!topmargin.empty())
432 << VSpace(topmargin).asLyXCommand() << '\n';
433 if (!rightmargin.empty())
434 os << "\\rightmargin "
435 << VSpace(rightmargin).asLyXCommand() << '\n';
436 if (!bottommargin.empty())
437 os << "\\bottommargin "
438 << VSpace(bottommargin).asLyXCommand() << '\n';
439 if (!headheight.empty())
440 os << "\\headheight "
441 << VSpace(headheight).asLyXCommand() << '\n';
442 if (!headsep.empty())
444 << VSpace(headsep).asLyXCommand() << '\n';
445 if (!footskip.empty())
447 << VSpace(footskip).asLyXCommand() << '\n';
448 os << "\\secnumdepth " << secnumdepth
449 << "\n\\tocdepth " << tocdepth
450 << "\n\\paragraph_separation "
451 << string_paragraph_separation[paragraph_separation]
452 << "\n\\defskip " << defskip.asLyXCommand()
453 << "\n\\quotes_language "
454 << string_quotes_language[quotes_language] << '\n';
455 switch (quotes_times) {
456 // An output operator for insetquotes would be nice
457 case InsetQuotes::SingleQ:
458 os << "\\quotes_times 1\n"; break;
459 case InsetQuotes::DoubleQ:
460 os << "\\quotes_times 2\n"; break;
462 os << "\\papercolumns " << columns
463 << "\n\\papersides " << sides
464 << "\n\\paperpagestyle " << pagestyle << '\n';
465 for (int i = 0; i < 4; ++i) {
466 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
467 if (user_defined_bullets[i].getFont() != -1) {
468 os << "\\bullet " << i
470 << user_defined_bullets[i].getFont()
472 << user_defined_bullets[i].getCharacter()
474 << user_defined_bullets[i].getSize()
475 << "\n\\end_bullet\n";
478 os << "\\bulletLaTeX " << i
480 << user_defined_bullets[i].getText()
481 << "\"\n\\end_bullet\n";
486 os << "\\tracking_changes " << tracking_changes << "\n";
488 if (tracking_changes) {
489 AuthorList::Authors::const_iterator it = authorlist.begin();
490 AuthorList::Authors::const_iterator end = authorlist.end();
491 for (; it != end; ++it) {
492 os << "\\author " << it->second << "\n";
498 bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
499 TexRow & texrow) const
501 os << "\\documentclass";
503 LyXTextClass const & tclass = getLyXTextClass();
505 ostringstream clsoptions; // the document class options.
507 if (tokenPos(tclass.opt_fontsize(),
508 '|', fontsize) >= 0) {
509 // only write if existing in list (and not default)
510 clsoptions << fontsize << "pt,";
515 (paperpackage == PACKAGE_NONE)) {
518 clsoptions << "a3paper,";
521 clsoptions << "a4paper,";
524 clsoptions << "letterpaper,";
527 clsoptions << "a5paper,";
530 clsoptions << "b5paper,";
532 case PAPER_EXECUTIVEPAPER:
533 clsoptions << "executivepaper,";
535 case PAPER_LEGALPAPER:
536 clsoptions << "legalpaper,";
544 if (sides != tclass.sides()) {
546 case LyXTextClass::OneSide:
547 clsoptions << "oneside,";
549 case LyXTextClass::TwoSides:
550 clsoptions << "twoside,";
556 if (columns != tclass.columns()) {
558 clsoptions << "twocolumn,";
560 clsoptions << "onecolumn,";
564 && orientation == ORIENTATION_LANDSCAPE)
565 clsoptions << "landscape,";
567 // language should be a parameter to \documentclass
568 if (language->babel() == "hebrew"
569 && default_language->babel() != "hebrew")
570 // This seems necessary
571 features.useLanguage(default_language);
573 ostringstream language_options;
574 bool const use_babel = features.useBabel();
576 language_options << features.getLanguages();
577 language_options << language->babel();
578 if (lyxrc.language_global_options)
579 clsoptions << language_options.str() << ',';
582 // the user-defined options
583 if (!options.empty()) {
584 clsoptions << options << ',';
587 string strOptions(STRCONV(clsoptions.str()));
588 if (!strOptions.empty()) {
589 strOptions = rtrim(strOptions, ",");
590 os << '[' << strOptions << ']';
593 os << '{' << tclass.latexname() << "}\n";
595 // end of \documentclass defs
597 // font selection must be done before loading fontenc.sty
598 // The ae package is not needed when using OT1 font encoding.
599 if (fonts != "default" &&
600 (fonts != "ae" || lyxrc.fontenc != "default")) {
601 os << "\\usepackage{" << fonts << "}\n";
604 os << "\\usepackage{aecompl}\n";
608 // this one is not per buffer
609 if (lyxrc.fontenc != "default") {
610 os << "\\usepackage[" << lyxrc.fontenc
615 if (inputenc == "auto") {
616 string const doc_encoding =
617 language->encoding()->LatexName();
619 // Create a list with all the input encodings used
621 std::set<string> encodings =
622 features.getEncodingSet(doc_encoding);
624 os << "\\usepackage[";
625 std::copy(encodings.begin(), encodings.end(),
626 std::ostream_iterator<string>(os, ","));
627 os << doc_encoding << "]{inputenc}\n";
629 } else if (inputenc != "default") {
630 os << "\\usepackage[" << inputenc
635 // At the very beginning the text parameters.
636 if (paperpackage != PACKAGE_NONE) {
637 switch (paperpackage) {
641 os << "\\usepackage{a4}\n";
645 os << "\\usepackage{a4wide}\n";
648 case PACKAGE_WIDEMARGINSA4:
649 os << "\\usepackage[widemargins]{a4}\n";
655 os << "\\usepackage{geometry}\n";
657 os << "\\geometry{verbose";
658 if (orientation == ORIENTATION_LANDSCAPE)
660 switch (papersize2) {
661 case VM_PAPER_CUSTOM:
662 if (!paperwidth.empty())
665 if (!paperheight.empty())
666 os << ",paperheight="
669 case VM_PAPER_USLETTER:
670 os << ",letterpaper";
672 case VM_PAPER_USLEGAL:
675 case VM_PAPER_USEXECUTIVE:
676 os << ",executivepaper";
697 // default papersize ie VM_PAPER_DEFAULT
698 switch (lyxrc.default_papersize) {
699 case PAPER_DEFAULT: // keep compiler happy
701 os << ",letterpaper";
703 case PAPER_LEGALPAPER:
706 case PAPER_EXECUTIVEPAPER:
707 os << ",executivepaper";
723 if (!topmargin.empty())
724 os << ",tmargin=" << topmargin;
725 if (!bottommargin.empty())
726 os << ",bmargin=" << bottommargin;
727 if (!leftmargin.empty())
728 os << ",lmargin=" << leftmargin;
729 if (!rightmargin.empty())
730 os << ",rmargin=" << rightmargin;
731 if (!headheight.empty())
732 os << ",headheight=" << headheight;
733 if (!headsep.empty())
734 os << ",headsep=" << headsep;
735 if (!footskip.empty())
736 os << ",footskip=" << footskip;
741 if (tokenPos(tclass.opt_pagestyle(),
742 '|', pagestyle) >= 0) {
743 if (pagestyle == "fancy") {
744 os << "\\usepackage{fancyhdr}\n";
747 os << "\\pagestyle{" << pagestyle << "}\n";
751 if (secnumdepth != tclass.secnumdepth()) {
752 os << "\\setcounter{secnumdepth}{"
757 if (tocdepth != tclass.tocdepth()) {
758 os << "\\setcounter{tocdepth}{"
764 if (paragraph_separation) {
765 switch (defskip.kind()) {
766 case VSpace::SMALLSKIP:
767 os << "\\setlength\\parskip{\\smallskipamount}\n";
769 case VSpace::MEDSKIP:
770 os << "\\setlength\\parskip{\\medskipamount}\n";
772 case VSpace::BIGSKIP:
773 os << "\\setlength\\parskip{\\bigskipamount}\n";
776 os << "\\setlength\\parskip{"
777 << defskip.length().asLatexString()
780 default: // should never happen // Then delete it.
781 os << "\\setlength\\parskip{\\medskipamount}\n";
786 os << "\\setlength\\parindent{0pt}\n";
790 // Now insert the LyX specific LaTeX commands...
792 // The optional packages;
793 string lyxpreamble(features.getPackages());
795 // this might be useful...
796 lyxpreamble += "\n\\makeatletter\n";
798 // Some macros LyX will need
799 string tmppreamble(features.getMacros());
801 if (!tmppreamble.empty()) {
802 lyxpreamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
803 "LyX specific LaTeX commands.\n"
804 + tmppreamble + '\n';
807 // the text class specific preamble
808 tmppreamble = features.getTClassPreamble();
809 if (!tmppreamble.empty()) {
810 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
811 "Textclass specific LaTeX commands.\n"
812 + tmppreamble + '\n';
815 /* the user-defined preamble */
816 if (!preamble.empty()) {
817 lyxpreamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
818 "User specified LaTeX commands.\n"
822 // Itemize bullet settings need to be last in case the user
823 // defines their own bullets that use a package included
824 // in the user-defined preamble -- ARRae
825 // Actually it has to be done much later than that
826 // since some packages like frenchb make modifications
827 // at \begin{document} time -- JMarc
829 for (int i = 0; i < 4; ++i) {
830 if (user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
831 if (bullets_def.empty())
832 bullets_def="\\AtBeginDocument{\n";
833 bullets_def += " \\renewcommand{\\labelitemi";
835 // `i' is one less than the item to modify
848 bullets_def += "}{" +
849 user_defined_bullets[i].getText()
854 if (!bullets_def.empty())
855 lyxpreamble += bullets_def + "}\n\n";
857 // We try to load babel late, in case it interferes
858 // with other packages.
860 string tmp = lyxrc.language_package;
861 if (!lyxrc.language_global_options
862 && tmp == "\\usepackage{babel}")
863 tmp = string("\\usepackage[") +
864 STRCONV(language_options.str()) +
866 lyxpreamble += tmp + "\n";
867 lyxpreamble += features.getBabelOptions();
870 lyxpreamble += "\\makeatother\n";
872 // dvipost settings come after everything else
873 if (tracking_changes) {
876 "\\dvipost{osstart color push Red}\n"
877 "\\dvipost{osend color pop}\n"
878 "\\dvipost{cbstart color push Blue}\n"
879 "\\dvipost{cbend color pop} \n";
883 int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
884 for (int j = 0; j != nlines; ++j) {
892 void BufferParams::setPaperStuff()
894 papersize = PAPER_DEFAULT;
895 char const c1 = paperpackage;
896 if (c1 == PACKAGE_NONE) {
897 char const c2 = papersize2;
898 if (c2 == VM_PAPER_USLETTER)
899 papersize = PAPER_USLETTER;
900 else if (c2 == VM_PAPER_USLEGAL)
901 papersize = PAPER_LEGALPAPER;
902 else if (c2 == VM_PAPER_USEXECUTIVE)
903 papersize = PAPER_EXECUTIVEPAPER;
904 else if (c2 == VM_PAPER_A3)
905 papersize = PAPER_A3PAPER;
906 else if (c2 == VM_PAPER_A4)
907 papersize = PAPER_A4PAPER;
908 else if (c2 == VM_PAPER_A5)
909 papersize = PAPER_A5PAPER;
910 else if ((c2 == VM_PAPER_B3) || (c2 == VM_PAPER_B4) ||
912 papersize = PAPER_B5PAPER;
913 } else if ((c1 == PACKAGE_A4) || (c1 == PACKAGE_A4WIDE) ||
914 (c1 == PACKAGE_WIDEMARGINSA4))
915 papersize = PAPER_A4PAPER;
919 void BufferParams::useClassDefaults()
921 LyXTextClass const & tclass = textclasslist[textclass];
923 sides = tclass.sides();
924 columns = tclass.columns();
925 pagestyle = tclass.pagestyle();
926 options = tclass.options();
927 secnumdepth = tclass.secnumdepth();
928 tocdepth = tclass.tocdepth();
932 bool BufferParams::hasClassDefaults() const
934 LyXTextClass const & tclass = textclasslist[textclass];
936 return (sides == tclass.sides()
937 && columns == tclass.columns()
938 && pagestyle == tclass.pagestyle()
939 && options == tclass.options()
940 && secnumdepth == tclass.secnumdepth()
941 && tocdepth == tclass.tocdepth());
945 LyXTextClass const & BufferParams::getLyXTextClass() const
947 return textclasslist[textclass];
951 void BufferParams::readPreamble(LyXLex & lex)
953 if (lex.getString() != "\\begin_preamble")
954 lyxerr << "Error (BufferParams::readPreamble):"
955 "consistency check failed." << endl;
957 preamble = lex.getLongString("\\end_preamble");
961 void BufferParams::readLanguage(LyXLex & lex)
963 if (!lex.next()) return;
965 string const tmptok = lex.getString();
967 // check if tmptok is part of tex_babel in tex-defs.h
968 language = languages.getLanguage(tmptok);
970 // Language tmptok was not found
971 language = default_language;
972 lyxerr << "Warning: Setting language `"
973 << tmptok << "' to `" << language->lang()
979 void BufferParams::readGraphicsDriver(LyXLex & lex)
981 if (!lex.next()) return;
983 string const tmptok = lex.getString();
984 // check if tmptok is part of tex_graphics in tex_defs.h
987 string const test = tex_graphics[n++];
989 if (test == tmptok) {
990 graphicsDriver = tmptok;
992 } else if (test == "last_item") {
994 "Warning: graphics driver `$$Token' not recognized!\n"
995 " Setting graphics driver to `default'.\n");
996 graphicsDriver = "default";
1003 string const BufferParams::paperSizeName() const
1005 char real_papersize = papersize;
1006 if (real_papersize == PAPER_DEFAULT)
1007 real_papersize = lyxrc.default_papersize;
1009 switch (real_papersize) {
1018 case PAPER_EXECUTIVEPAPER:
1020 case PAPER_LEGALPAPER:
1022 case PAPER_USLETTER:
1029 string const BufferParams::dvips_options() const
1034 && papersize2 == VM_PAPER_CUSTOM
1035 && !lyxrc.print_paper_dimension_flag.empty()
1036 && !paperwidth.empty()
1037 && !paperheight.empty()) {
1038 // using a custom papersize
1039 result = lyxrc.print_paper_dimension_flag;
1040 result += ' ' + paperwidth;
1041 result += ',' + paperheight;
1043 string const paper_option = paperSizeName();
1044 if (paper_option != "letter" ||
1045 orientation != ORIENTATION_LANDSCAPE) {
1046 // dvips won't accept -t letter -t landscape.
1047 // In all other cases, include the paper size
1049 result = lyxrc.print_paper_flag;
1050 result += ' ' + paper_option;
1053 if (orientation == ORIENTATION_LANDSCAPE &&
1054 papersize2 != VM_PAPER_CUSTOM)
1055 result += ' ' + lyxrc.print_landscape_flag;