* BufferParams.{cpp,h}:

- pass graphics driver to geometry (bug 5613)
	- put papersize options to package call, not in \geometry
	  which broke compilation in some cases (bug 3838)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27917 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-12-19 09:32:04 +00:00
parent 28bfbe4e03
commit 3d48607f1a
2 changed files with 49 additions and 22 deletions

View File

@ -1129,71 +1129,71 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
texrow.newline();
}
if (use_geometry || nonstandard_papersize) {
os << "\\usepackage{geometry}\n";
texrow.newline();
os << "\\geometry{verbose";
odocstringstream ods;
if (!getGraphicsDriver("geometry").empty())
ods << getGraphicsDriver("geometry");
if (orientation == ORIENTATION_LANDSCAPE)
os << ",landscape";
ods << ",landscape";
switch (papersize) {
case PAPER_CUSTOM:
if (!paperwidth.empty())
os << ",paperwidth="
ods << ",paperwidth="
<< from_ascii(paperwidth);
if (!paperheight.empty())
os << ",paperheight="
ods << ",paperheight="
<< from_ascii(paperheight);
break;
case PAPER_USLETTER:
os << ",letterpaper";
ods << ",letterpaper";
break;
case PAPER_USLEGAL:
os << ",legalpaper";
ods << ",legalpaper";
break;
case PAPER_USEXECUTIVE:
os << ",executivepaper";
ods << ",executivepaper";
break;
case PAPER_A3:
os << ",a3paper";
ods << ",a3paper";
break;
case PAPER_A4:
os << ",a4paper";
ods << ",a4paper";
break;
case PAPER_A5:
os << ",a5paper";
ods << ",a5paper";
break;
case PAPER_B3:
os << ",b3paper";
ods << ",b3paper";
break;
case PAPER_B4:
os << ",b4paper";
ods << ",b4paper";
break;
case PAPER_B5:
os << ",b5paper";
ods << ",b5paper";
break;
default:
// default papersize ie PAPER_DEFAULT
switch (lyxrc.default_papersize) {
case PAPER_DEFAULT: // keep compiler happy
case PAPER_USLETTER:
os << ",letterpaper";
ods << ",letterpaper";
break;
case PAPER_USLEGAL:
os << ",legalpaper";
ods << ",legalpaper";
break;
case PAPER_USEXECUTIVE:
os << ",executivepaper";
ods << ",executivepaper";
break;
case PAPER_A3:
os << ",a3paper";
ods << ",a3paper";
break;
case PAPER_A4:
os << ",a4paper";
ods << ",a4paper";
break;
case PAPER_A5:
os << ",a5paper";
ods << ",a5paper";
break;
case PAPER_B5:
os << ",b5paper";
ods << ",b5paper";
break;
case PAPER_B3:
case PAPER_B4:
@ -1201,6 +1201,13 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
break;
}
}
docstring const g_options = trim(ods.str(), ",");
os << "\\usepackage";
if (!g_options.empty())
os << '[' << g_options << ']';
os << "{geometry}\n";
texrow.newline();
os << "\\geometry{verbose";
if (!topmargin.empty())
os << ",tmargin=" << from_ascii(Length(topmargin).asLatexString());
if (!bottommargin.empty())
@ -2103,6 +2110,24 @@ string BufferParams::babelCall(string const & lang_opts) const
}
docstring BufferParams::getGraphicsDriver(string const & package) const
{
docstring result;
if (package == "geometry") {
if (graphicsDriver == "dvips"
|| graphicsDriver == "dvipdfm"
|| graphicsDriver == "pdftex"
|| graphicsDriver == "vtex")
result = from_ascii(graphicsDriver);
else if (graphicsDriver == "dvipdfmx")
result = from_ascii("dvipdfm");
}
return result;
}
void BufferParams::writeEncodingPreamble(odocstream & os,
LaTeXFeatures & features, TexRow & texrow) const
{

View File

@ -310,6 +310,8 @@ public:
std::string paperSizeName(PapersizePurpose purpose) const;
/// set up if and how babel is called
std::string babelCall(std::string const & lang_opts) const;
/// return supported drivers for specific packages
docstring getGraphicsDriver(std::string const & package) const;
/// handle inputenc etc.
void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
TexRow & texrow) const;