mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix hyperref-soul conflict and sanitize hyperref management
* src/BufferParams.cpp: - always require hyperref if it's used. - only call PDFOptions::writeLaTeX if hyperref is required (and not provided by textclass). * src/PDFOptions.{cpp,h}: - (writeLaTeX): remove unneeded hyper_required argument * src/LaTeXFeatures.cpp: - special definition for pdflatex ct markup when hyperref is used (fix bug 4504). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22629 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f0f485e40d
commit
804e912910
@ -884,6 +884,9 @@ void BufferParams::validate(LaTeXFeatures & features) const
|
||||
features.require("pifont");
|
||||
}
|
||||
}
|
||||
|
||||
if (pdfoptions().use_hyperref)
|
||||
features.require("hyperref");
|
||||
}
|
||||
|
||||
|
||||
@ -1243,10 +1246,18 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|
||||
// before hyperref. Then hyperref has a chance to detect babel.
|
||||
// * Has to be loaded before the "LyX specific LaTeX commands" to
|
||||
// avoid errors with algorithm floats.
|
||||
odocstringstream oss;
|
||||
// use hyperref explicitely when it is required
|
||||
pdfoptions().writeLaTeX(oss, features.isRequired("hyperref"));
|
||||
lyxpreamble += oss.str();
|
||||
/** FIXME: If the textclass provides hyperref, the GUI is
|
||||
non-functional. To fix this, we would need requires("hyperref")
|
||||
below, pass getTextClass().provides("hyperref") to
|
||||
pdfoptions().writeLaTeX(oss) and load the options via
|
||||
\hypersetup instead of tha package's optional argument.
|
||||
**/
|
||||
if (features.mustProvide("hyperref")) {
|
||||
odocstringstream oss;
|
||||
pdfoptions().writeLaTeX(oss);
|
||||
lyxpreamble += oss.str();
|
||||
}
|
||||
|
||||
// this might be useful...
|
||||
lyxpreamble += "\n\\makeatletter\n";
|
||||
|
@ -173,6 +173,16 @@ static string const changetracking_dvipost_def =
|
||||
"\\newcommand{\\lyxdeleted}[3]{%\n"
|
||||
"\\changestart\\overstrikeon#3\\overstrikeoff\\changeend}\n";
|
||||
|
||||
static string const changetracking_xcolor_soul_def =
|
||||
"%% Change tracking with soul\n"
|
||||
"\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
|
||||
"\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\st{#3}}}\n";
|
||||
|
||||
static string const changetracking_xcolor_soul_hyperref_def =
|
||||
"%% Change tracking with soul\n"
|
||||
"\\newcommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}}{}#3}}\n"
|
||||
"\\newcommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\st{#3}}{}}}\n";
|
||||
|
||||
static string const changetracking_none_def =
|
||||
"\\newcommand{\\lyxadded}[3]{#3}\n"
|
||||
"\\newcommand{\\lyxdeleted}[3]{}\n";
|
||||
@ -810,9 +820,11 @@ string const LaTeXFeatures::getMacros() const
|
||||
<< cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
|
||||
|
||||
macros.precision(prec);
|
||||
|
||||
macros << "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
|
||||
<< "\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\st{#3}}}\n";
|
||||
|
||||
if (mustProvide("hyperref"))
|
||||
macros << changetracking_xcolor_soul_hyperref_def;
|
||||
else
|
||||
macros << changetracking_xcolor_soul_def;
|
||||
}
|
||||
|
||||
if (mustProvide("ct-none"))
|
||||
|
@ -50,6 +50,7 @@ bool PDFOptions::empty() const
|
||||
&& pdfusetitle == x.pdfusetitle;
|
||||
}
|
||||
|
||||
|
||||
void PDFOptions::writeFile(ostream & os) const
|
||||
{
|
||||
os << "\\use_hyperref " << convert<string>(use_hyperref) << '\n';
|
||||
@ -85,11 +86,9 @@ void PDFOptions::writeFile(ostream & os) const
|
||||
os << "\\pdf_quoted_options \"" << quoted_options << "\"\n";
|
||||
}
|
||||
|
||||
void PDFOptions::writeLaTeX(odocstream & os, bool hyper_required) const
|
||||
|
||||
void PDFOptions::writeLaTeX(odocstream & os) const
|
||||
{
|
||||
if (!use_hyperref && !hyper_required)
|
||||
return;
|
||||
|
||||
string opt;
|
||||
|
||||
opt = "\\usepackage[";
|
||||
@ -200,6 +199,7 @@ string PDFOptions::quoted_options_get() const
|
||||
return quoted_options;
|
||||
}
|
||||
|
||||
|
||||
// set implicit settings for hyperref
|
||||
void PDFOptions::clear()
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
/// output to lyx header
|
||||
void writeFile(std::ostream &) const;
|
||||
/// output to tex header
|
||||
void writeLaTeX(odocstream &, bool hyper_required) const;
|
||||
void writeLaTeX(odocstream &) const;
|
||||
/// read tokens from lyx header
|
||||
std::string readToken(Lexer &lex, std::string const & token);
|
||||
/// set implicit settings for hyperref
|
||||
|
Loading…
Reference in New Issue
Block a user