]> git.lyx.org Git - features.git/commitdiff
output changes by means of xcolor and soul
authorMichael Schmitt <michael.schmitt@teststep.org>
Sun, 13 May 2007 15:17:57 +0000 (15:17 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Sun, 13 May 2007 15:17:57 +0000 (15:17 +0000)
  - 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

lib/chkconfig.ltx
src/Buffer.cpp
src/BufferView.cpp
src/Changes.cpp
src/Color.cpp
src/Color.h
src/LaTeXFeatures.cpp
src/insets/InsetTabular.cpp
src/rowpainter.cpp

index d33e4737c2ae206706e61fe091756851b677dc36..5804ec10c551748d514d70352a2415dff8824eb9 100644 (file)
 \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}
index 1a2766eb21df34ff0159ac7af0e3ce59e60882e3..4db5afad6b9ad014672efd700d1ca01a9002cfc8 100644 (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");
+                       }
                }
        }
 
index 3ab54445556f2c11afbdf55e9d2d68df8a4720e9..03efbffd2b577e60b08b4ae77df5cb9eb6a76958 100644 (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;
index fec558e56ea77d893579e0e55425e67a8eb18de8..6b5979b0bb00115ca351c6e18a7ff3fbdf08aaa7 100644 (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;
index 908090755017464533fe0c832fe97f872bf3a810..c96033fcc8e1aee0993f92abe5afccbaa4866c00 100644 (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",
index 372c1a50253d4273467e80f9b0e2628397926380..8a394ac49752b5a0f4a127e58a57a91152e9cb1c 100644 (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
index c5f73a9cdf4e1cadead2ccabf85a0f096e6d3c3a..f8cd82f252c5c99289b71bf95980230afc0aa53c 100644 (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();
 }
index fe48b698437333bdbaadf584a606de395bddfca2..f9c8d3fe520c7c3b1d58a2dc8bd52940bf3da089 100644 (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)) {
index afb99897ef0b64bd72462bf0c282eccba01ea035..a8a49d0666e63883cb6ec358b47622cb8650c637 100644 (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;
        }
 }