output changes by means of xcolor and soul

- when exporting with pdflatex 
  - when exporting with latex and dvipost is not available
rename two colors (strikeout => deletedtext, newtext => addedtext)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18284 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Michael Schmitt 2007-05-13 15:17:57 +00:00
parent 1fb2456cec
commit 8684c07664
9 changed files with 82 additions and 43 deletions

View File

@ -238,14 +238,17 @@
\TestPackage{longtable}
\TestPackage{natbib}
\TestPackage{nomencl}
\TestPackage{pdfcolmk}
\TestPackage{prettyref}
\TestPackage{preview}
\TestPackage{rotating}
\TestPackage{setspace}
\TestPackage{soul}
\TestPackage{subfigure}
\TestPackage{textcomp}
\TestPackage{varioref}
\TestPackage{url}
\TestPackage{xcolor}
% The test for the graphics package is slightly more involved...
\newcommand\groption{dvips}

View File

@ -506,18 +506,22 @@ bool Buffer::readDocument(Lexer & lex)
}
if (params().outputChanges) {
if (!LaTeXFeatures::isAvailable("dvipost")) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
LaTeXFeatures::isAvailable("xcolor");
if (!dvipost && !xcolorsoul) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output, "
"because dvipost is not installed.\n"
"If you are familiar with TeX, consider redefining "
"\\lyxinserted and \\lyxdeleted in the LaTeX preamble."));
} else {
"because neither dvipost nor xcolor/soul are installed.\n"
"Please install these packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
} else if (!xcolorsoul) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output "
"when using pdflatex.\n"
"If you are familiar with TeX, consider redefining "
"\\lyxinserted and \\lyxdeleted in the LaTeX preamble."));
"when using pdflatex, because xcolor and soul are not installed.\n"
"Please install both packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
}
}
@ -1215,14 +1219,30 @@ void Buffer::validate(LaTeXFeatures & features) const
TextClass const & tclass = params().getTextClass();
if (params().outputChanges) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
LaTeXFeatures::isAvailable("xcolor");
if (features.runparams().flavor == OutputParams::LATEX) {
if (LaTeXFeatures::isAvailable("dvipost")) {
if (dvipost) {
features.require("ct-dvipost");
features.require("dvipost");
} else {
} else if (xcolorsoul) {
features.require("ct-xcolor-soul");
features.require("soul");
features.require("xcolor");
} else {
features.require("ct-none");
}
} else if (features.runparams().flavor == OutputParams::PDFLATEX ) {
features.require("ct-none");
if (xcolorsoul) {
features.require("ct-xcolor-soul");
features.require("soul");
features.require("xcolor");
features.require("pdfcolmk"); // improves color handling in PDF output
} else {
features.require("ct-none");
}
}
}

View File

@ -891,18 +891,22 @@ Update::flags BufferView::dispatch(FuncRequest const & cmd)
case LFUN_CHANGES_OUTPUT:
buffer_->params().outputChanges = !buffer_->params().outputChanges;
if (buffer_->params().outputChanges) {
if (!LaTeXFeatures::isAvailable("dvipost")) {
bool dvipost = LaTeXFeatures::isAvailable("dvipost");
bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
LaTeXFeatures::isAvailable("xcolor");
if (!dvipost && !xcolorsoul) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output, "
"because dvipost is not installed.\n"
"If you are familiar with TeX, consider redefining "
"\\lyxinserted and \\lyxdeleted in the LaTeX preamble."));
} else {
"because neither dvipost nor xcolor/soul are installed.\n"
"Please install these packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
} else if (!xcolorsoul) {
Alert::warning(_("Changes not shown in LaTeX output"),
_("Changes will not be highlighted in LaTeX output "
"when using pdflatex.\n"
"If you are familiar with TeX, consider redefining "
"\\lyxinserted and \\lyxdeleted in the LaTeX preamble."));
"when using pdflatex, because xcolor and soul are not installed.\n"
"Please install both packages or redefine "
"\\lyxadded and \\lyxdeleted in the LaTeX preamble."));
}
}
break;

View File

@ -303,7 +303,7 @@ int Changes::latexMarkChange(odocstream & os, BufferParams const & bparams,
int column = 0;
if (oldChange.type != Change::UNCHANGED) {
os << '}'; // close \lyxinserted or \lyxdeleted
os << '}'; // close \lyxadded or \lyxdeleted
column++;
}
@ -318,7 +318,7 @@ int Changes::latexMarkChange(odocstream & os, BufferParams const & bparams,
os << str;
column += str.size();
} else if (change.type == Change::INSERTED) {
docstring str = "\\lyxinserted{" +
docstring str = "\\lyxadded{" +
bparams.authors().get(change.author).name() + "}{" +
chgTime + "}{";
os << str;

View File

@ -309,8 +309,8 @@ Color::Color()
{ eolmarker, N_("end-of-line marker"), "eolmarker", "Brown", "eolmarker" },
{ appendix, N_("appendix marker"), "appendix", "Brown", "appendix" },
{ changebar, N_("change bar"), "changebar", "Blue", "changebar" },
{ strikeout, N_("Deleted text"), "strikeout", "Red", "strikeout" },
{ newtext, N_("Added text"), "newtext", "Blue", "newtext" },
{ deletedtext, N_("Deleted text"), "deletedtext", "Red", "deletedtext" },
{ addedtext, N_("Added text"), "addedtext", "Blue", "addedtext" },
{ added_space, N_("added space markers"), "added_space", "Brown", "added_space" },
{ topline, N_("top/bottom line"), "topline", "Brown", "topline" },
{ tabularline, N_("table line"), "tabularline", "black",

View File

@ -153,10 +153,10 @@ public:
appendix,
/// changebar color
changebar,
/// strike-out color
strikeout,
/// deleted text color
deletedtext,
/// added text color
newtext,
addedtext,
/// Top and bottom line color
topline,
/// Table line color

View File

@ -178,18 +178,13 @@ static string const changetracking_dvipost_def =
"\\dvipost{osend color pop}\n"
"\\dvipost{cbstart color push Blue}\n"
"\\dvipost{cbend color pop}\n"
"\\newcommand{\\lyxinserted}[3]{\\changestart#3\\changeend}\n"
"\\newcommand{\\lyxadded}[3]{\\changestart#3\\changeend}\n"
"\\newcommand{\\lyxdeleted}[3]{%\n"
"\\changestart\\overstrikeon#3\\overstrikeoff\\changeend}\n";
// TODO
//static string const changetracking_soul_def =
// "\\newcommand{\\lyxinserted}[3]{\\uwave{\\textcolor{blue}{#3}}}\n"
// "\\newcommand{\\lyxdeleted}[3]{\\sout{\\textcolor{red}{#3}}}";
static string const changetracking_none_def =
"\\newcommand{\\lyxinserted}[3]{#3}\n"
"\\newcommand{\\lyxdeleted}[3]{}";
"\\newcommand{\\lyxadded}[3]{#3}\n"
"\\newcommand{\\lyxdeleted}[3]{}\n";
/////////////////////////////////////////////////////////////////////
@ -411,7 +406,10 @@ char const * simplefeatures[] = {
"nicefrac",
"tipa",
"framed",
"pdfcolmk",
"soul",
"textcomp",
"xcolor",
};
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
@ -643,10 +641,24 @@ string const LaTeXFeatures::getMacros() const
getFloatDefinitions(macros);
// change tracking
if (mustProvide("dvipost"))
if (mustProvide("ct-dvipost")) {
macros << changetracking_dvipost_def;
if (mustProvide("ct-none"))
}
if (mustProvide("ct-xcolor-soul")) {
RGBColor cadd = RGBColor(lcolor.getX11Name(Color::addedtext));
macros << "\\providecolor{lyxadded}{rgb}{"
<< cadd.r/255 << ',' << cadd.g/255 << ',' << cadd.b/255 << "}\n";
RGBColor cdel = RGBColor(lcolor.getX11Name(Color::deletedtext));
macros << "\\providecolor{lyxdeleted}{rgb}{"
<< cdel.r/255 << ',' << cdel.g/255 << ',' << cdel.b/255 << "}\n";
macros << "\\newcommand{\\lyxadded}[3]{\\textcolor{lyxadded}{#3}}\n"
<< "\\newcommand{\\lyxdeleted}[3]{\\textcolor{lyxdeleted}{\\st{#3}}}\n";
}
if (mustProvide("ct-none")) {
macros << changetracking_none_def;
}
return macros.str();
}

View File

@ -3105,8 +3105,8 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int y,
Color::color onoffcol = Color::tabularonoffline;
if (erased) {
col = Color::strikeout;
onoffcol = Color::strikeout;
col = Color::deletedtext;
onoffcol = Color::deletedtext;
}
if (!tabular.topAlreadyDrawn(cell)) {

View File

@ -368,9 +368,9 @@ void RowPainter::paintChars(pos_type & vpos, Font const & font,
if (prev_change != Change::UNCHANGED) {
Font copy(font);
if (prev_change == Change::DELETED) {
copy.setColor(Color::strikeout);
copy.setColor(Color::deletedtext);
} else if (prev_change == Change::INSERTED) {
copy.setColor(Color::newtext);
copy.setColor(Color::addedtext);
}
x_ += pain_.text(int(x_), yo_, s, copy);
} else {
@ -669,7 +669,7 @@ void RowPainter::paintLast()
if (par_.isInserted(par_.size()) || par_.isDeleted(par_.size())) {
FontMetrics const & fm = theFontMetrics(bv_.buffer()->params().getFont());
int const length = fm.maxAscent() / 2;
Color::color col = par_.isInserted(par_.size()) ? Color::newtext : Color::strikeout;
Color::color col = par_.isInserted(par_.size()) ? Color::addedtext : Color::deletedtext;
pain_.line(int(x_) + 1, yo_ + 2, int(x_) + 1, yo_ + 2 - length, col,
Painter::line_solid, Painter::line_thick);
@ -779,7 +779,7 @@ void RowPainter::paintText()
= theFontMetrics(bv_.buffer()->params().getFont());
int const middle = yo_ - fm.maxAscent() / 3;
pain_.line(last_strikeout_x, middle, int(x_), middle,
Color::strikeout, Painter::line_solid, Painter::line_thin);
Color::deletedtext, Painter::line_solid, Painter::line_thin);
running_strikeout = false;
}
@ -834,7 +834,7 @@ void RowPainter::paintText()
= theFontMetrics(bv_.buffer()->params().getFont());
int const middle = yo_ - fm.maxAscent() / 3;
pain_.line(last_strikeout_x, middle, int(x_), middle,
Color::strikeout, Painter::line_solid, Painter::line_thin);
Color::deletedtext, Painter::line_solid, Painter::line_thin);
running_strikeout = false;
}
}