Fix output of change tracked documents (also fixes bug 1031)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9535 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2005-01-24 17:12:19 +00:00
parent bb3f0fbec4
commit 04a3819779
19 changed files with 184 additions and 23 deletions

View File

@ -1,3 +1,7 @@
2005-01-15 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* ui/classic.ui, ui/stdmenus.ui: add output-changes.
2005-01-24 Angus Leeming <leeming@lyx.org>
* reLyX/configure.ac: revert Jean-Marc's wrapping of the

View File

@ -1,3 +1,8 @@
2005-01-24 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LyX.py: format up to 240.
* lyx_1_4.py (convert_output_changes, revert_output_changes): new
2005-01-06 José Matos <jamatos@lyx.org>
* lyx_1_4.py (normalize_paragraph_params): add start_of_appendix

View File

@ -46,7 +46,7 @@ format_relation = [("0_10", [210], ["0.10.7","0.10"]),
("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3"]),
("1_4", range(223,240), ["1.4.0cvs","1.4"])]
("1_4", range(223,241), ["1.4.0cvs","1.4"])]
def formats_list():

View File

@ -1533,6 +1533,24 @@ def normalize_paragraph_params(file):
i = i + 1
##
# Add/remove output_changes parameter
#
def convert_output_changes (file):
i = find_token(file.header, '\\tracking_changes', 0)
if i == -1:
file.warning("Malformed lyx file: Missing '\\tracking_changes'.")
return
file.header.insert(i+1, '\\output_changes true')
def revert_output_changes (file):
i = find_token(file.header, '\\output_changes', 0)
if i == -1:
return
del file.header[i]
##
# Convertion hub
#
@ -1556,9 +1574,11 @@ convert = [[223, [insert_tracking_changes, add_end_header, remove_color_default,
normalize_papersize, strip_end_space]],
[237, [use_x_boolean]],
[238, [update_latexaccents]],
[239, [normalize_paragraph_params]]]
[239, [normalize_paragraph_params]],
[240, [convert_output_changes]]]
revert = [[238, []],
revert = [[239, [revert_output_changes]],
[238, []],
[237, []],
[236, [use_x_binary]],
[235, [denormalize_papersize, remove_begin_body,remove_begin_header,

View File

@ -320,6 +320,8 @@ Menuset
Item "Merge Changes...|M" "merge-changes"
Item "Accept All Changes|A" "accept-all-changes"
Item "Reject All Changes|R" "reject-all-changes"
Item "Show changes in output|S" "output-changes"
End
#
# LAYOUT MENU

View File

@ -372,6 +372,7 @@ Menuset
Item "Merge Changes...|M" "merge-changes"
Item "Accept All Changes|A" "accept-all-changes"
Item "Reject All Changes|R" "reject-all-changes"
Item "Show changes in output|S" "output-changes"
End
#

View File

@ -34,6 +34,7 @@
#include "gettext.h"
#include "intl.h"
#include "insetiterator.h"
#include "LaTeXFeatures.h"
#include "lyx_cb.h" // added for Dispatch functions
#include "lyx_main.h"
#include "lyxfind.h"
@ -972,6 +973,14 @@ FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
flag.setOnOff(buf->params().tracking_changes);
break;
case LFUN_OUTPUT_CHANGES: {
LaTeXFeatures features(*buf, buf->params(), false);
flag.enabled(buf && buf->params().tracking_changes
&& features.isAvailable("dvipost"));
flag.setOnOff(buf->params().output_changes);
break;
}
case LFUN_MERGE_CHANGES:
case LFUN_ACCEPT_CHANGE: // what about these two
case LFUN_REJECT_CHANGE: // what about these two
@ -1071,6 +1080,13 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & cmd)
trackChanges();
break;
case LFUN_OUTPUT_CHANGES: {
Buffer * buf = bv_->buffer();
bool const state = buf->params().output_changes;
buf->params().output_changes = !state;
break;
}
case LFUN_MERGE_CHANGES:
owner_->getDialogs().show("changes");
break;

View File

@ -1,3 +1,22 @@
2005-01-24 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* LaTeXFeatures.[Ch]: Add a static list packages_ that
holds the contens of packages.lst. New functions getAvailable
and isAvailable to parse and check that list, resp.
* LyXAction.C:
* lfuns.h:
* BufferView_pimpl.C: new LFUN_OUTPUT_CHANGES.
* bufferparams.[Ch]: new param output_changes.
* Buffer.C: increase file format to 240.
Use output_changes and isVailable.
* changes.[Ch]:
* paragraph.C:
* paragraph_pimpl.C: Use output_changes and isVailable.
2005-01-23 Angus Leeming <leeming@lyx.org>
* output_latex.C: #include "insetbibitem.h", rather than

View File

@ -22,6 +22,7 @@
#include "Floating.h"
#include "FloatList.h"
#include "language.h"
#include "lyxlex.h"
#include "lyx_sty.h"
#include "lyxrc.h"
@ -30,6 +31,7 @@
#include <sstream>
using lyx::support::IsSGMLFilename;
using lyx::support::LibFileSearch;
using lyx::support::MakeRelPath;
using lyx::support::OnlyPath;
@ -44,6 +46,9 @@ using std::set;
namespace biblio = lyx::biblio;
LaTeXFeatures::PackagesList LaTeXFeatures::packages_;
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool n)
: buffer_(&b), params_(p), nice_(n)
{}
@ -66,6 +71,39 @@ void LaTeXFeatures::require(string const & name)
}
void LaTeXFeatures::getAvailable()
{
LyXLex lex(0, 0);
string real_file = LibFileSearch("", "packages.lst");
if (real_file.empty())
return;
lex.setFile(real_file);
if (!lex.isOK())
return;
bool finished = false;
// Parse config-file
while (lex.isOK() && !finished) {
switch (lex.lex()) {
case LyXLex::LEX_FEOF:
finished = true;
break;
default:
string const name = lex.getString();
PackagesList::const_iterator begin = packages_.begin();
PackagesList::const_iterator end = packages_.end();
if (find(begin, end, name) == end)
packages_.push_back(name);
}
}
return;
}
void LaTeXFeatures::useLayout(string const & layoutname)
{
// Some code to avoid loops in dependency definition
@ -111,6 +149,14 @@ bool LaTeXFeatures::isRequired(string const & name) const
}
bool LaTeXFeatures::isAvailable(string const & name) const
{
if (packages_.empty())
getAvailable();
return find(packages_.begin(), packages_.end(), name) != packages_.end();
}
void LaTeXFeatures::addExternalPreamble(string const & preamble)
{
FeaturesList::const_iterator begin = preamble_snippets_.begin();

View File

@ -62,8 +62,12 @@ public:
void addExternalPreamble(std::string const &);
/// Provide a string name-space to the requirements
void require(std::string const & name);
/// Which of the required packages are installed?
static void getAvailable();
/// Is the package required?
bool isRequired(std::string const & name) const;
/// Is the (required) package available?
bool isAvailable(std::string const & name) const;
///
void useFloat(std::string const & name);
///
@ -96,6 +100,10 @@ private:
FeaturesList features_;
///
FeaturesList preamble_snippets_;
/// The available (required) packages
typedef std::list<std::string> PackagesList;
///
static PackagesList packages_;
///
typedef std::set<Language const *> LanguageList;
///

View File

@ -305,6 +305,7 @@ void LyXAction::init()
{ LFUN_ESCAPE, "escape", ReadOnly },
{ LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", NoBuffer },
{ LFUN_TRACK_CHANGES, "track-changes", Noop },
{ LFUN_OUTPUT_CHANGES, "output-changes", Noop },
{ LFUN_MERGE_CHANGES, "merge-changes", Noop },
{ LFUN_ACCEPT_CHANGE, "accept-change", Noop },
{ LFUN_REJECT_CHANGE, "reject-change", Noop },

View File

@ -139,7 +139,7 @@ extern BufferList bufferlist;
namespace {
int const LYX_FORMAT = 239;
int const LYX_FORMAT = 240;
} // namespace anon
@ -1185,7 +1185,8 @@ void Buffer::validate(LaTeXFeatures & features) const
{
LyXTextClass const & tclass = params().getLyXTextClass();
if (params().tracking_changes) {
if (features.isAvailable("dvipost") && params().tracking_changes
&& params().output_changes) {
features.require("dvipost");
features.require("color");
}

View File

@ -341,6 +341,7 @@ BufferParams::BufferParams()
cite_engine = biblio::ENGINE_BASIC;
use_bibtopic = false;
tracking_changes = false;
output_changes = false;
secnumdepth = 3;
tocdepth = 3;
language = default_language;
@ -508,6 +509,8 @@ string const BufferParams::readToken(LyXLex & lex, string const & token)
lex >> use_bibtopic;
} else if (token == "\\tracking_changes") {
lex >> tracking_changes;
} else if (token == "\\output_changes") {
lex >> output_changes;
} else if (token == "\\branch") {
lex.next();
string branch = lex.getString();
@ -711,6 +714,7 @@ void BufferParams::writeFile(ostream & os) const
}
os << "\\tracking_changes " << convert<string>(tracking_changes) << "\n";
os << "\\output_changes " << convert<string>(output_changes) << "\n";
if (tracking_changes) {
AuthorList::Authors::const_iterator it = pimpl_->authorlist.begin();
@ -1100,7 +1104,7 @@ bool BufferParams::writeLaTeX(ostream & os, LaTeXFeatures & features,
lyxpreamble += "\\makeatother\n";
// dvipost settings come after everything else
if (tracking_changes) {
if (features.isAvailable("dvipost") && tracking_changes && output_changes) {
lyxpreamble +=
"\\dvipostlayout\n"
"\\dvipost{osstart color push Red}\n"

View File

@ -209,6 +209,14 @@ public:
bool use_bibtopic;
/// revision tracking for this buffer ?
bool tracking_changes;
/** This param decides if change tracking marks should be output
* (using the dvipost package) or if the current "state" of the
* document should be output instead. Since dvipost needs dvi
* specials, it only works with dvi/ps output (the param will be
* ignored with other output flavors and disabled when dbipost is
* not installed).
*/
bool output_changes;
/// Time ago we agreed that this was a buffer property [ale990407]
std::string parentname;
///

View File

@ -495,11 +495,12 @@ void Changes::check() const
int Changes::latexMarkChange(std::ostream & os,
Change::Type const old, Change::Type const change)
Change::Type const old, Change::Type const change,
bool const & output)
{
if (old == change)
if (!output || old == change)
return 0;
string const start("\\changestart{}");
string const end("\\changeend{}");
string const son("\\overstrikeon{}");

View File

@ -89,7 +89,8 @@ public:
/// output latex to mark a transition between two changetypes
/// returns length of text outputted
static int latexMarkChange(std::ostream & os, Change::Type old, Change::Type change);
static int latexMarkChange(std::ostream & os, Change::Type old,
Change::Type change, bool const & output);
/// output .lyx file format for transitions between changes
static void lyxMarkChange(std::ostream & os, int & column,

View File

@ -354,6 +354,7 @@ enum kb_action {
LFUN_PREVIOUSBUFFER,
// 270
LFUN_WORDS_COUNT,
LFUN_OUTPUT_CHANGES, // jspitzm 20050121
LFUN_LASTACTION // end of the table
};

View File

@ -27,6 +27,7 @@
#include "debug.h"
#include "gettext.h"
#include "language.h"
#include "LaTeXFeatures.h"
#include "lyxfont.h"
#include "lyxrc.h"
#include "lyxrow.h"
@ -900,6 +901,15 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
}
LyXFont basefont;
LaTeXFeatures features(buf, bparams, runparams.nice);
// output change tracking marks only if desired,
// if dvipost is installed,
// and with dvi/ps (other formats don't work)
bool const output = bparams.output_changes
&& runparams.flavor == OutputParams::LATEX
&& features.isAvailable("dvipost");
// Maybe we have to create a optional argument.
pos_type body_pos = beginOfBody();
@ -1010,23 +1020,28 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
Change::Type change = pimpl_->lookupChange(i);
column += Changes::latexMarkChange(os, running_change, change);
column += Changes::latexMarkChange(os, running_change,
change, output);
running_change = change;
OutputParams rp = runparams;
rp.free_spacing = style->free_spacing;
rp.local_language = font.language()->babel();
rp.intitle = style->intitle;
pimpl_->simpleTeXSpecialChars(buf, bparams,
os, texrow, rp,
font, running_font,
basefont, outerfont, open_font,
running_change,
*style, i, column, c);
// do not output text which is marked deleted
// if change tracking output is not desired
if (output || running_change != Change::DELETED) {
OutputParams rp = runparams;
rp.free_spacing = style->free_spacing;
rp.local_language = font.language()->babel();
rp.intitle = style->intitle;
pimpl_->simpleTeXSpecialChars(buf, bparams,
os, texrow, rp,
font, running_font,
basefont, outerfont, open_font,
running_change,
*style, i, column, c);
}
}
column += Changes::latexMarkChange(os,
running_change, Change::UNCHANGED);
running_change, Change::UNCHANGED, output);
// If we have an open font definition, we have to close it
if (open_font) {

View File

@ -503,9 +503,17 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
break;
}
// output change tracking marks only if desired,
// if dvipost is installed,
// and with dvi/ps (other formats don't work)
LaTeXFeatures features(buf, bparams, runparams.nice);
bool const output = bparams.output_changes
&& runparams.flavor == OutputParams::LATEX
&& features.isAvailable("dvipost");
if (inset->isTextInset()) {
column += Changes::latexMarkChange(os, running_change,
Change::UNCHANGED);
Change::UNCHANGED, output);
running_change = Change::UNCHANGED;
}