[LyX/master] Add native changebars

Juergen Spitzmueller spitz at lyx.org
Tue Dec 24 16:56:41 UTC 2019


commit dc4823e7590de9891b5f04de298f046fa33f71b0
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Dec 24 18:12:22 2019 +0100

    Add native changebars
    
    Fixes #10750
---
 development/FORMAT               |    4 ++
 lib/Makefile.am                  |    1 -
 lib/chkconfig.ltx                |    1 +
 lib/doc/UserGuide.lyx            |   43 +++++++++++++++++++++++-
 lib/doc/de/UserGuide.lyx         |   66 ++++++++++++++++++------------------
 lib/layouts/changebars.module    |   30 -----------------
 lib/lyx2lyx/lyx_2_4.py           |   39 +++++++++++++++++++++-
 src/Buffer.cpp                   |   17 ++++++---
 src/Buffer.h                     |    4 ++-
 src/BufferParams.cpp             |    9 +++++
 src/BufferParams.h               |    2 +
 src/Converter.cpp                |    2 +-
 src/LaTeXFeatures.cpp            |   67 +++++++++++++++++++++++++++++++++----
 src/frontends/qt/GuiDocument.cpp |   25 ++++++++++++++
 src/frontends/qt/GuiDocument.h   |    2 +
 src/frontends/qt/Makefile.am     |    1 +
 src/tex2lyx/Preamble.cpp         |    5 +++
 src/tex2lyx/Preamble.h           |    1 +
 src/version.h                    |    4 +-
 19 files changed, 238 insertions(+), 85 deletions(-)

diff --git a/development/FORMAT b/development/FORMAT
index e43dad5..4b782d5 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
 
 -----------------------
 
+2019-12-24 Jürgen Spitzmüller <spitz at lyx.org>
+ 	* Format incremented to 590: Add native changebar solution via buffer param
+          \change_bars.
+
 2019-08-14 Jürgen Spitzmüller <spitz at lyx.org>
  	* Format incremented to 589: Height now is totalheight in graphics.
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d0b0b7b..83e58bb 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -2310,7 +2310,6 @@ dist_layouts_DATA =\
 	layouts/bxjsbook.layout \
 	layouts/bxjsreport.layout \
 	layouts/bxjsslide.layout \
-	layouts/changebars.module \
 	layouts/chess.layout \
 	layouts/chessboard.module \
 	layouts/cl2emult.layout \
diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx
index 73b1daa..14230d4 100644
--- a/lib/chkconfig.ltx
+++ b/lib/chkconfig.ltx
@@ -342,6 +342,7 @@
 \TestPackage{CJK}
 \TestPackage{calc}
 \TestPackage{cancel}
+\TestPackage{changebar}
 \TestPackage{chapterbib}
 \TestPackage{chemgreek}
 \TestPackage{chessboard}
diff --git a/lib/doc/UserGuide.lyx b/lib/doc/UserGuide.lyx
index b61eb30..6f82164 100644
--- a/lib/doc/UserGuide.lyx
+++ b/lib/doc/UserGuide.lyx
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 583
+\lyxformat 590
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -149,6 +149,7 @@ logicalmkup
 \tablestyle default
 \tracking_changes true
 \output_changes false
+\change_bars false
 \html_math_output 0
 \html_css_as_file 0
 \html_be_strict true
@@ -38204,6 +38205,8 @@ The toolbar has two buttons to handle notes because notes are often important
 \end_layout
 
 \begin_layout Standard
+
+\change_deleted -712698321 1577206802
 To show the changes made in the output you need the \SpecialChar LaTeX
  package 
 \series bold
@@ -38232,6 +38235,8 @@ literal "true"
 
  or in the package manager of your \SpecialChar LaTeX
 -system.
+\change_unchanged
+
 \end_layout
 
 \begin_layout Section
@@ -46863,6 +46868,42 @@ Objects
 \end_layout
 
 \begin_layout Section
+
+\change_inserted -712698321 1577206827
+Change Tracking
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1577206929
+Here you can do some settings related to change tracking (see sec.
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sec:Change-Tracking"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+).
+ Alternatively to the menu or toolbar, you can set here whether changes
+ are being tracked and whether they are shown in the output.
+\end_layout
+
+\begin_layout Standard
+
+\change_inserted -712698321 1577207214
+Additionally, you can advise LyX to place a change bar in the margin of
+ the output.
+ This might be useful to make changed passages more salient.
+\end_layout
+
+\begin_layout Section
 Numbering & TOC
 \end_layout
 
diff --git a/lib/doc/de/UserGuide.lyx b/lib/doc/de/UserGuide.lyx
index 5a35933..e34f4f1 100644
--- a/lib/doc/de/UserGuide.lyx
+++ b/lib/doc/de/UserGuide.lyx
@@ -1,5 +1,5 @@
 #LyX 2.4 created this file. For more info see https://www.lyx.org/
-\lyxformat 583
+\lyxformat 590
 \begin_document
 \begin_header
 \save_transient_properties true
@@ -154,6 +154,7 @@ logicalmkup
 \tablestyle default
 \tracking_changes false
 \output_changes false
+\change_bars false
 \html_math_output 0
 \html_css_as_file 0
 \html_be_strict false
@@ -36511,38 +36512,6 @@ Die Werkzeugleiste hat zwei Schaltknöpfe, um Notizen zu behandeln, weil
  diese zur Beschreibung einer Änderung oft wichtig sind.
 \end_layout
 
-\begin_layout Standard
-Um Änderungen in der Druckausgabe anzeigen zu können, benötigen Sie das
- \SpecialChar LaTeX
--Paket 
-\series bold
-dvipost
-\series default
-
-\begin_inset Index idx
-status collapsed
-
-\begin_layout Plain Layout
-\SpecialChar LaTeX
--Paket ! dvipost
-\end_layout
-
-\end_inset
-
-.
- Sie finden es im \SpecialChar TeX
--Katalog, 
-\begin_inset CommandInset citation
-LatexCommand cite
-key "TeX-Katalog"
-literal "true"
-
-\end_inset
-
-, oder im Paket-Manager Ihres \SpecialChar LaTeX
--Systems.
-\end_layout
-
 \begin_layout Section
 Vergleich von Dokumenten
 \begin_inset CommandInset label
@@ -44337,6 +44306,37 @@ Objekte
 \end_layout
 
 \begin_layout Section
+Änderungsverfolgung
+\end_layout
+
+\begin_layout Standard
+Hier können Sie einige Einstellungen zur Änderungsverfolgung (vgl.
+ Abschnitt
+\begin_inset space ~
+\end_inset
+
+
+\begin_inset CommandInset ref
+LatexCommand ref
+reference "sec:Änderungsverfolgung"
+plural "false"
+caps "false"
+noprefix "false"
+
+\end_inset
+
+) vornehmen.
+ Alternativ zum Menü und der Werkzeugleiste können Sie hier bestimmen, ob
+ Änderungen aufgezeichnet werden und ob sie in der Ausgabe angezeigt werden.
+\end_layout
+
+\begin_layout Standard
+Zusätzlich können Sie hier einen Änderungsbalken aktivieren, der in der
+ Ausgabe in den Seitenrand gedruckt wird, um geänderte Stellen sichtbarer
+ zu machen.
+\end_layout
+
+\begin_layout Section
 Nummerierung
 \begin_inset space ~
 \end_inset
diff --git a/lib/layouts/changebars.module b/lib/layouts/changebars.module
deleted file mode 100644
index f0c27f3..0000000
--- a/lib/layouts/changebars.module
+++ /dev/null
@@ -1,30 +0,0 @@
-#\DeclareLyXModule[changebar.sty]{Change Tracking Bars}
-#\DeclareCategory{Annotation & Revision}
-#
-#DescriptionBegin
-#Enables LyX to add vertical change bars in the margin of PDF output
-#when Show Changes in Output is turned on and pdflatex output format is chosen.
-#DescriptionEnd
-#
-#Author: Paul A. Rubin (rubin at msu.edu)
-#Based on code proposed by Juergen Spitzmueller
-#(http://comments.gmane.org/gmane.editors.lyx.general/66666).
-#
-# Note: the \providecommand statements are necessary to avoid
-# error messages from the \renewcommand statements if change
-# tracking is turned off in the document.
-#
-
-Format 80
-
-AddToPreamble
-  \usepackage{changebar}
-  \providecommand{\lyxadded}[4][]{}
-  \providecommand{\lyxdeleted}{}
-  \renewcommand{\lyxadded}[4][]{
-    {\protect\cbstart\color{lyxadded}{}#4\protect\cbend}
-  }
-  \renewcommand{\lyxdeleted}[4][]{%
-    {\protect\cbstart\color{lyxdeleted}\sout{#4}\protect\cbend}
-  }
-EndPreamble
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index 5b1a87c..5d59e34 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -3635,6 +3635,39 @@ def convert_totalheight(document):
             document.body.insert(k, "\theight " + newheight) 
         i = j + 1
 
+
+def convert_changebars(document):
+    " Converts the changebars module to native solution "
+
+    if not "changebars" in document.get_module_list():
+        return
+
+    i = find_token(document.header, "\\output_changes", 0)
+    if i == -1:
+        document.warning("Malformed LyX document! Missing \\output_changes header.")
+        document.del_module("changebars")
+        return
+
+    document.header.insert(i, "\\change_bars true")
+    document.del_module("changebars")
+
+
+def revert_changebars(document):
+    " Converts native changebar param to module "
+
+    i = find_token(document.header, "\\change_bars", 0)
+    if i == -1:
+        document.warning("Malformed LyX document! Missing \\change_bars header.")
+        return
+
+    val = get_value(document.header, "\\change_bars", i)
+
+    if val == "true":
+        document.add_module("changebars")
+
+    del document.header[i]
+
+
 ##
 # Conversion hub
 #
@@ -3685,10 +3718,12 @@ convert = [
            [586, []],
            [587, [convert_pagesizenames]],
            [588, []],
-           [589, [convert_totalheight]]
+           [589, [convert_totalheight]],
+           [590, [convert_changebars]]
           ]
 
-revert =  [[588, [revert_totalheight]],
+revert =  [[589, [revert_changebars]],
+           [588, [revert_totalheight]],
            [587, [revert_memoir_endnotes,revert_enotez,revert_theendnotes]],
            [586, [revert_pagesizenames]],
            [585, [revert_dupqualicites]],
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 6cebf5d..2d3160e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -321,7 +321,7 @@ public:
 	/// If there was an error when previewing, on the next preview we do
 	/// a fresh compile (e.g. in case the user installed a package that
 	/// was missing).
-	bool preview_error_;
+	bool require_fresh_start_;
 
 	/// Cache the references associated to a label and their positions
 	/// in the buffer.
@@ -456,7 +456,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
 	  file_fully_loaded(false), file_format(LYX_FORMAT), need_format_backup(false),
 	  ignore_parent(false),  toc_backend(owner), macro_lock(false),
 	  checksum_(0), wa_(0),  gui_(0), undo_(*owner), bibinfo_cache_valid_(false),
-	  cite_labels_valid_(false), have_bibitems_(false), preview_error_(false),
+	  cite_labels_valid_(false), have_bibitems_(false), require_fresh_start_(false),
 	  inset(0), preview_loader_(0), cloned_buffer_(cloned_buffer),
 	  clone_list_(0), doing_export(false),
 	  tracked_changes_present_(0), externally_modified_(false), parent_buffer(0),
@@ -489,7 +489,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
 	layout_position = cloned_buffer_->d->layout_position;
 	preview_file_ = cloned_buffer_->d->preview_file_;
 	preview_format_ = cloned_buffer_->d->preview_format_;
-	preview_error_ = cloned_buffer_->d->preview_error_;
+	require_fresh_start_ = cloned_buffer_->d->require_fresh_start_;
 	tracked_changes_present_ = cloned_buffer_->d->tracked_changes_present_;
 }
 
@@ -1246,9 +1246,14 @@ void Buffer::setFullyLoaded(bool value)
 }
 
 
-bool Buffer::lastPreviewError() const
+bool Buffer::freshStartRequired() const
 {
-	return d->preview_error_;
+	return d->require_fresh_start_;
+}
+
+void Buffer::requireFreshStart(bool const b) const
+{
+	d->require_fresh_start_ = b;
 }
 
 
@@ -4728,7 +4733,7 @@ Buffer::ExportStatus Buffer::preview(string const & format, bool includeall) con
 	Impl * theimpl = isClone() ? d->cloned_buffer_->d : d;
 	theimpl->preview_file_ = previewFile;
 	theimpl->preview_format_ = format;
-	theimpl->preview_error_ = (status != ExportSuccess);
+	theimpl->require_fresh_start_ = (status != ExportSuccess);
 
 	if (status != ExportSuccess)
 		return status;
diff --git a/src/Buffer.h b/src/Buffer.h
index 7ed9f05..621c294 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -681,7 +681,9 @@ public:
 	ExportStatus preview(std::string const & format) const;
 	/// true if there was a previous preview this session of this buffer and
 	/// there was an error on the previous preview of this buffer.
-	bool lastPreviewError() const;
+	bool freshStartRequired() const;
+	///
+	void requireFreshStart(bool const b) const;
 
 private:
 	///
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 3b0b831..399faa3 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -410,6 +410,7 @@ BufferParams::BufferParams()
 	save_transient_properties = true;
 	track_changes = false;
 	output_changes = false;
+	change_bars = false;
 	use_default_options = true;
 	maintain_unincluded_children = false;
 	secnumdepth = 3;
@@ -951,6 +952,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
 		lex >> track_changes;
 	} else if (token == "\\output_changes") {
 		lex >> output_changes;
+	} else if (token == "\\change_bars") {
+		lex >> change_bars;
 	} else if (token == "\\branch") {
 		lex.eatLine();
 		docstring branch = lex.getDocString();
@@ -1468,6 +1471,10 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
 	   << (save_transient_properties ? convert<string>(output_changes) : "false")
 	   << '\n';
 
+	os << "\\change_bars "
+	   << (save_transient_properties ? convert<string>(change_bars) : "false")
+	   << '\n';
+
 	os << "\\html_math_output " << html_math_output << '\n'
 	   << "\\html_css_as_file " << html_css_as_file << '\n'
 	   << "\\html_be_strict " << convert<string>(html_be_strict) << '\n';
@@ -1525,6 +1532,8 @@ void BufferParams::validate(LaTeXFeatures & features) const
 		default:
 			break;
 		}
+		if (change_bars)
+			features.require("changebar");
 	}
 
 	// Floats with 'Here definitely' as default setting.
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 3a5cd29..5b5a16f 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -434,6 +434,8 @@ public:
 	 */
 	bool output_changes;
 	///
+	bool change_bars;
+	///
 	bool compressed;
 
 	/// the author list for the document
diff --git a/src/Converter.cpp b/src/Converter.cpp
index 2ffd98a..d5686f6 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -863,7 +863,7 @@ Converters::RetVal Converters::runLaTeX(Buffer const & buffer, string const & co
 	string const name = buffer.latexName();
 	LaTeX latex(command, runparams, FileName(makeAbsPath(name)),
 	            buffer.filePath(), buffer.layoutPos(),
-	            buffer.isClone(), buffer.lastPreviewError());
+	            buffer.isClone(), buffer.freshStartRequired());
 	TeXErrors terr;
 	// The connection closes itself at the end of the scope when latex is
 	// destroyed. One cannot close (and destroy) buffer while the converter is
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 533f5ad..3462067 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -241,6 +241,18 @@ static docstring const changetracking_dvipost_def = from_ascii(
 	"\\dvipost{osstart color push Red}\n"
 	"\\dvipost{osend color pop}\n"
 	"\\dvipost{cbstart color push Blue}\n"
+	"\\dvipost{cbrule 0pt}\n"
+	"\\dvipost{cbend color pop}\n"
+	"\\DeclareRobustCommand{\\lyxadded}[4][]{\\changestart#4\\changeend}\n"
+	"\\DeclareRobustCommand{\\lyxdeleted}[4][]{%\n"
+	"\\changestart\\overstrikeon#4\\overstrikeoff\\changeend}\n");
+
+static docstring const changetracking_dvipost_cb_def = from_ascii(
+	"%% Change tracking with dvipost\n"
+	"\\dvipostlayout\n"
+	"\\dvipost{osstart color push Red}\n"
+	"\\dvipost{osend color pop}\n"
+	"\\dvipost{cbstart color push Blue}\n"
 	"\\dvipost{cbend color pop}\n"
 	"\\DeclareRobustCommand{\\lyxadded}[4][]{\\changestart#4\\changeend}\n"
 	"\\DeclareRobustCommand{\\lyxdeleted}[4][]{%\n"
@@ -252,12 +264,36 @@ static docstring const changetracking_xcolor_ulem_def = from_ascii(
 	"\\DeclareRobustCommand{\\lyxdeleted}[4][]{{\\color{lyxdeleted}\\lyxsout{#4}}}\n"
 	"\\DeclareRobustCommand{\\lyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
 
+static docstring const changetracking_xcolor_ulem_cb_def = from_ascii(
+	"%% Change tracking with ulem and changebars\n"
+	"\\DeclareRobustCommand{\\lyxadded}[4][]{{%\n"
+	"    \\protect\\cbstart\\color{lyxadded}{}#4%\n"
+	"    \\protect\\cbend%\n"
+	"}}\n"
+	"\\DeclareRobustCommand{\\lyxdeleted}[4][]{{%\n"
+	"    \\protect\\cbstart\\color{lyxdeleted}\\lyxsout{#4}%\n"
+	"    \\protect\\cbend%\n"
+	"}}\n"
+	"\\DeclareRobustCommand{\\lyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
+
 static docstring const changetracking_xcolor_ulem_hyperref_def = from_ascii(
-	"%% Change tracking with ulem\n"
+	"%% Change tracking with ulem and hyperref\n"
 	"\\DeclareRobustCommand{\\lyxadded}[4][]{{\\texorpdfstring{\\color{lyxadded}{}}{}#4}}\n"
 	"\\DeclareRobustCommand{\\lyxdeleted}[4][]{{\\texorpdfstring{\\color{lyxdeleted}\\lyxsout{#4}}{}}}\n"
 	"\\DeclareRobustCommand{\\lyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
 
+static docstring const changetracking_xcolor_ulem_hyperref_cb_def = from_ascii(
+	"%% Change tracking with ulem, hyperref and changebars\n"
+	"\\DeclareRobustCommand{\\lyxadded}[4][]{{%\n"
+	"    \\texorpdfstring{\\protect\\cbstart\\color{lyxadded}{}}{}#4%\n"
+	"    \\texorpdfstring{\\protect\\cbend}{}%/n"
+	"}}\n"
+	"\\DeclareRobustCommand{\\lyxdeleted}[4][]{{%\n"
+	"    \\texorpdfstring{\\protect\\cbstart\\color{lyxdeleted}\\lyxsout{#4}%\n"
+	"    \\protect\\cbend}{}%\n"
+	"}}\n"
+	"\\DeclareRobustCommand{\\lyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
+
 static docstring const changetracking_tikz_math_sout_def = from_ascii(
 	"%% Strike out display math with tikz\n"
 	"\\usepackage{tikz}\n"
@@ -1176,6 +1212,10 @@ string const LaTeXFeatures::getPackages() const
 	// The rest of these packages are somewhat more complicated
 	// than those above.
 
+	if (mustProvide("changebar") && !mustProvide("ct-dvipost")) {
+		packages << "\\usepackage{changebar}\n";
+	}
+
 	if (mustProvide("footnote")) {
 		if (isRequired("hyperref"))
 			packages << "\\usepackage{footnotehyper}\n";
@@ -1615,8 +1655,12 @@ TexString LaTeXFeatures::getMacros() const
 		macros << lyxref_def << '\n';
 
 	// change tracking
-	if (mustProvide("ct-dvipost"))
-		macros << changetracking_dvipost_def;
+	if (mustProvide("ct-dvipost")) {
+		if (isRequired("changebar"))
+			macros << changetracking_dvipost_cb_def;
+		else
+			macros << changetracking_dvipost_def;
+	}
 
 	if (mustProvide("ct-xcolor-ulem")) {
 		streamsize const prec = macros.os().precision(2);
@@ -1631,14 +1675,21 @@ TexString LaTeXFeatures::getMacros() const
 
 		macros.os().precision(prec);
 
-		if (isRequired("hyperref"))
-			macros << changetracking_xcolor_ulem_hyperref_def;
-		else
-			macros << changetracking_xcolor_ulem_def;
+		if (isRequired("changebar")) {
+			if (isRequired("hyperref"))
+				macros << changetracking_xcolor_ulem_hyperref_cb_def;
+			else
+				macros << changetracking_xcolor_ulem_cb_def;
+		} else {
+			if (isRequired("hyperref"))
+				macros << changetracking_xcolor_ulem_hyperref_def;
+			else
+				macros << changetracking_xcolor_ulem_def;
+		}
 	}
 
 	if (mustProvide("ct-tikz-math-sout"))
-			macros << changetracking_tikz_math_sout_def;
+		macros << changetracking_tikz_math_sout_def;
 
 	if (mustProvide("ct-none"))
 		macros << changetracking_none_def;
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index 56f4468..095c0a2 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -1305,6 +1305,14 @@ GuiDocument::GuiDocument(GuiView & lv)
 	connect(colorModule->delBoxBackgroundTB, SIGNAL(clicked()),
 		this, SLOT(deleteBoxBackgroundColor()));
 
+	// change tracking
+	changesModule = new UiWidget<Ui::ChangeTrackingUi>(this);
+	connect(changesModule->trackChangesCB, SIGNAL(clicked()),
+		this, SLOT(change_adaptor()));
+	connect(changesModule->outputChangesCB, SIGNAL(clicked()),
+		this, SLOT(change_adaptor()));
+	connect(changesModule->changeBarsCB, SIGNAL(clicked()),
+		this, SLOT(change_adaptor()));
 
 	// numbering
 	numberingModule = new UiWidget<Ui::NumberingUi>(this);
@@ -1743,6 +1751,7 @@ GuiDocument::GuiDocument(GuiView & lv)
 	docPS->addPanel(marginsModule, N_("Page Margins"));
 	docPS->addPanel(langModule, N_("Language"));
 	docPS->addPanel(colorModule, N_("Colors"));
+	docPS->addPanel(changesModule, N_("Change Tracking"));
 	docPS->addPanel(numberingModule, N_("Numbering & TOC"));
 	docPS->addPanel(biblioModule, N_("Bibliography"));
 	docPS->addPanel(indicesModule, N_("Indexes"));
@@ -3798,6 +3807,17 @@ void GuiDocument::applyView()
 	pdf.quoted_options = pdf.quoted_options_check(
 				fromqstr(pdfSupportModule->optionsLE->text()));
 
+	// change tracking
+	bp_.track_changes = changesModule->trackChangesCB->isChecked();
+	bp_.output_changes = changesModule->outputChangesCB->isChecked();
+	bool const cb_switched_off = (bp_.change_bars
+				      && !changesModule->changeBarsCB->isChecked());
+	bp_.change_bars = changesModule->changeBarsCB->isChecked();
+	if (cb_switched_off)
+		// if change bars have been switched off,
+		// we need to ditch the aux file
+		buffer().requireFreshStart(true);
+
 	// reset trackers
 	nonModuleChanged_ = false;
 	shellescapeChanged_ = false;
@@ -4391,6 +4411,11 @@ void GuiDocument::paramsToDialog()
 	pdfSupportModule->optionsLE->setText(
 		toqstr(pdf.quoted_options));
 
+	// change tracking
+	changesModule->trackChangesCB->setChecked(bp_.track_changes);
+	changesModule->outputChangesCB->setChecked(bp_.output_changes);
+	changesModule->changeBarsCB->setChecked(bp_.change_bars);
+
 	// Make sure that the bc is in the INITIAL state
 	if (bc().policy().buttonStatus(ButtonPolicy::RESTORE))
 		bc().restore();
diff --git a/src/frontends/qt/GuiDocument.h b/src/frontends/qt/GuiDocument.h
index 9647f3b..4d7cc80 100644
--- a/src/frontends/qt/GuiDocument.h
+++ b/src/frontends/qt/GuiDocument.h
@@ -20,6 +20,7 @@
 
 #include "ui_BiblioUi.h"
 #include "ui_ColorUi.h"
+#include "ui_ChangeTrackingUi.h"
 #include "ui_DocumentUi.h"
 #include "ui_FontUi.h"
 #include "ui_LanguageUi.h"
@@ -174,6 +175,7 @@ private:
 	UiWidget<Ui::MarginsUi> *marginsModule;
 	UiWidget<Ui::LanguageUi> *langModule;
 	UiWidget<Ui::ColorUi> *colorModule;
+	UiWidget<Ui::ChangeTrackingUi> *changesModule;
 	UiWidget<Ui::NumberingUi> *numberingModule;
 	UiWidget<Ui::BiblioUi> *biblioModule;
 	UiWidget<Ui::MathsUi> *mathsModule;
diff --git a/src/frontends/qt/Makefile.am b/src/frontends/qt/Makefile.am
index 27b4edd..f5f75cb 100644
--- a/src/frontends/qt/Makefile.am
+++ b/src/frontends/qt/Makefile.am
@@ -279,6 +279,7 @@ UIFILES = \
 	BranchUi.ui \
 	BulletsUi.ui \
 	ChangesUi.ui \
+	ChangeTrackingUi.ui \
 	CharacterUi.ui \
 	CitationUi.ui \
 	ColorUi.ui \
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index b489859..8b327b1 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -555,6 +555,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
 	//h_notefontcolor;
 	//h_options;
 	h_output_changes          = "false";
+	h_change_bars             = "false";
 	h_output_sync             = "0";
 	//h_output_sync_macro
 	h_papercolumns            = "1";
@@ -1782,6 +1783,9 @@ void Preamble::handle_package(Parser &p, string const & name,
 		}
 	}
 
+	else if (name == "changebar")
+		h_output_changes = "true";
+
 	else if (!in_lyx_preamble) {
 		if (options.empty())
 			h_preamble << "\\usepackage{" << name << '}';
@@ -2022,6 +2026,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc, string const & outfiled
 		os << "\\listings_params " << h_listings_params << "\n";
 	os << "\\tracking_changes " << h_tracking_changes << "\n"
 	   << "\\output_changes " << h_output_changes << "\n"
+	   << "\\change_bars " << h_change_bars << "\n"
 	   << "\\html_math_output " << h_html_math_output << "\n"
 	   << "\\html_css_as_file " << h_html_css_as_file << "\n"
 	   << "\\html_be_strict " << h_html_be_strict << "\n"
diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h
index de20b5e..42c6069 100644
--- a/src/tex2lyx/Preamble.h
+++ b/src/tex2lyx/Preamble.h
@@ -202,6 +202,7 @@ private:
 	std::string h_notefontcolor;
 	std::string h_options;
 	std::string h_output_changes;
+	std::string h_change_bars;
 	std::string h_output_sync;
 	std::string h_output_sync_macro;
 	std::string h_papercolumns;
diff --git a/src/version.h b/src/version.h
index 4c96416..ee529fc 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 589 // spitz: height > totalheight
-#define LYX_FORMAT_TEX2LYX 589
+#define LYX_FORMAT_LYX 590 // spitz: changebars
+#define LYX_FORMAT_TEX2LYX 590
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER


More information about the lyx-cvs mailing list