#include "Changes.h"
#include "Author.h"
+#include "Buffer.h"
#include "BufferParams.h"
#include "LaTeXFeatures.h"
+#include "Paragraph.h"
+#include "TocBackend.h"
#include "support/debug.h"
-
+#include "support/gettext.h"
#include "support/lassert.h"
#include <ostream>
authorList.get(it->change.author).setUsed(true);
}
+
+void Changes::addToToc(DocIterator const & cdit, Buffer const & buffer) const
+{
+ if (table_.empty())
+ return;
+
+ Toc & change_list = buffer.tocBackend().toc("change");
+ AuthorList const & author_list = buffer.params().authors();
+ DocIterator dit = cdit;
+
+ ChangeTable::const_iterator it = table_.begin();
+ ChangeTable::const_iterator const itend = table_.end();
+ for (; it != itend; ++it) {
+ docstring str;
+ switch (it->change.type) {
+ case Change::UNCHANGED:
+ continue;
+ case Change::DELETED:
+ // 0x2702 is a scissors symbol in the Dingbats unicode group.
+ str.push_back(0x2702);
+ break;
+ case Change::INSERTED:
+ // 0x2702 is the hand writting symbol in the Dingbats unicode group.
+ str.push_back(0x270d);
+ break;
+ }
+ dit.pos() = it->range.start;
+ str += " " + dit.paragraph().asString(it->range.start, it->range.end);
+ docstring const & author = author_list.get(it->change.author).name();
+ Toc::const_iterator it = change_list.item(0, author);
+ if (it == change_list.end()) {
+ change_list.push_back(TocItem(dit, 0, author));
+ change_list.push_back(TocItem(dit, 1, str));
+ } else {
+ it++;
+ change_list.insert(it, TocItem(dit, 1, str));
+ }
+ }
+}
+
} // namespace lyx
namespace lyx {
class AuthorList;
+class Buffer;
+class DocIterator;
class Change {
public:
/// return true if there is a change in the given range (excluding end)
bool isChanged(pos_type start, pos_type end) const;
- ///
-
/// output latex to mark a transition between two change types
/// returns length of text outputted
static int latexMarkChange(odocstream & os, BufferParams const & bparams,
///
void checkAuthors(AuthorList const & authorList);
+ ///
+ void addToToc(DocIterator const & cdit, Buffer const & buffer) const;
+
private:
class Range {
public:
}
+void Paragraph::addChangesToToc(DocIterator const & cdit,
+ Buffer const & buf) const
+{
+ d->changes_.addToToc(cdit, buf);
+}
+
+
bool Paragraph::isChanged(pos_type start, pos_type end) const
{
LASSERT(start >= 0 && start <= size(), /**/);
class Counters;
class Cursor;
class CursorSlice;
+class DocIterator;
class DocumentClass;
class Inset;
class InsetBibitem;
class PainterInfo;
class ParagraphParameters;
class TexRow;
-
+class Toc;
class FontSpan {
public:
///
int id() const;
+ ///
+ void addChangesToToc(DocIterator const & cdit, Buffer const & buf) const;
///
Language const * getParLanguage(BufferParams const &) const;
///
}
+TocIterator Toc::item(int depth, docstring const & str) const
+{
+ if (empty())
+ return end();
+ TocIterator it = begin();
+ TocIterator itend = end();
+ for (; it != itend; --it) {
+ if (it->depth() == depth && it->str() == str)
+ break;
+ }
+ return it;
+}
+
+
void TocBackend::writePlaintextTocList(string const & type, odocstream & os) const
{
TocList::const_iterator cit = tocs_.find(type);
public:
typedef std::vector<TocItem>::const_iterator const_iterator;
const_iterator item(DocIterator const & dit) const;
+ /// Look for a TocItem given its depth and string.
+ /// \return The first matching item.
+ /// \retval end() if no item was found.
+ const_iterator item(int depth, docstring const & str) const;
};
typedef Toc::const_iterator TocIterator;
// and efficient way with the label type because Toc::item() do a linear
// seatch. Even if fixed, it might even not be desirable to do so if we
// want to support drag&drop of labels and references.
- return type != "label";
+ return type != "label" && type != "change";
}
return qt_("Labels and References");
if (type == "branch")
return qt_("List of Branches");
+ if (type == "change")
+ return qt_("List of Changes");
FloatList const & floats = bp.documentClass().floats();
if (floats.typeExist(type))
tocstring = par.asString(AS_STR_LABEL);
toc.push_back(TocItem(dit, toclevel - min_toclevel, tocstring));
}
+
+ // And now the list of changes.
+ par.addChangesToToc(dit, buffer());
}
}