]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Revert "Fix the display of column spacing in AMS environments"
[lyx.git] / src / Text.cpp
index bedf228b337aa5476950426998ca1d0121f2cb0d..187e3872312f2ff66f3edb5705906c85703f5cfe 100644 (file)
@@ -135,7 +135,7 @@ void breakParagraphConservative(BufferParams const & bparams,
        ParagraphList & pars, pit_type par_offset, pos_type pos)
 {
        // create a new paragraph
-       Paragraph & tmp = *pars.insert(next(pars.begin(), par_offset + 1),
+       Paragraph & tmp = *pars.insert(lyx::next(pars.begin(), par_offset + 1),
                                       Paragraph());
        Paragraph & par = pars[par_offset];
 
@@ -360,7 +360,7 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
        string const & token, Font & font, Change & change, ErrorList & errorList)
 {
        Buffer * buf = const_cast<Buffer *>(&owner_->buffer());
-       BufferParams const & bp = buf->params();
+       BufferParams & bp = buf->params();
 
        if (token[0] != '\\') {
                docstring dstr = lex.getDocString();
@@ -534,18 +534,25 @@ void Text::readParToken(Paragraph & par, Lexer & lex,
                int aid;
                time_t ct;
                is >> aid >> ct;
-               BufferParams::AuthorMap const & am = bp.author_map;
+               BufferParams::AuthorMap const & am = bp.author_map_;
                if (am.find(aid) == am.end()) {
-                       errorList.push_back(ErrorItem(_("Change tracking error"),
-                                           bformat(_("Unknown author index for change: %1$d\n"), aid),
-                                           par.id(), 0, par.size()));
-                       change = Change(Change::UNCHANGED);
-               } else {
-                       if (token == "\\change_inserted")
-                               change = Change(Change::INSERTED, am.find(aid)->second, ct);
-                       else
-                               change = Change(Change::DELETED, am.find(aid)->second, ct);
+                       errorList.push_back(ErrorItem(
+                               _("Change tracking author index missing"),
+                               bformat(_("A change tracking author information for index "
+                                         "%1$d is missing. This can happen after a wrong "
+                                         "merge by a version control system. In this case, "
+                                         "either fix the merge, or have this information "
+                                         "missing until the corresponding tracked changes "
+                                         "are merged or this user edits the file again.\n"),
+                                       aid),
+                               par.id(), par.size(), par.size() + 1
+                               ));
+                       bp.addAuthor(Author(aid));
                }
+               if (token == "\\change_inserted")
+                       change = Change(Change::INSERTED, am.find(aid)->second, ct);
+               else
+                       change = Change(Change::DELETED, am.find(aid)->second, ct);
        } else {
                lex.eatLine();
                errorList.push_back(ErrorItem(_("Unknown token"),
@@ -661,7 +668,7 @@ static void breakParagraph(Text & text, pit_type par_offset, pos_type pos,
        ParagraphList & pars = text.paragraphs();
        // create a new paragraph, and insert into the list
        ParagraphList::iterator tmp =
-               pars.insert(next(pars.begin(), par_offset + 1),
+               pars.insert(lyx::next(pars.begin(), par_offset + 1),
                            Paragraph());
 
        Paragraph & par = pars[par_offset];
@@ -1259,7 +1266,7 @@ void Text::selectWord(Cursor & cur, word_location loc)
 {
        LBUFERR(this == cur.text());
        CursorSlice from = cur.top();
-       CursorSlice to = cur.top();
+       CursorSlice to;
        getWord(from, to, loc);
        if (cur.top() != from)
                setCursor(cur, from.pit(), from.pos());
@@ -1636,14 +1643,14 @@ bool Text::backspacePos0(Cursor & cur)
        if (cur.lastpos() == 0
            || (cur.lastpos() == 1 && par.isSeparator(0))) {
                cur.recordUndo(prevcur.pit());
-               plist.erase(next(plist.begin(), cur.pit()));
+               plist.erase(lyx::next(plist.begin(), cur.pit()));
                needsUpdate = true;
        }
        // is previous par empty?
        else if (prevcur.lastpos() == 0
                 || (prevcur.lastpos() == 1 && prevpar.isSeparator(0))) {
                cur.recordUndo(prevcur.pit());
-               plist.erase(next(plist.begin(), prevcur.pit()));
+               plist.erase(lyx::next(plist.begin(), prevcur.pit()));
                needsUpdate = true;
        }
        // Pasting is not allowed, if the paragraphs have different
@@ -2043,13 +2050,25 @@ docstring Text::asString(pit_type beg, pit_type end, int options) const
 }
 
 
-void Text::forOutliner(docstring & os, size_t maxlen, bool shorten) const
+void Text::shortenForOutliner(docstring & str, size_t const maxlen)
+{
+       support::truncateWithEllipsis(str, maxlen);
+       docstring::iterator it = str.begin();
+       docstring::iterator end = str.end();
+       for (; it != end; ++it)
+               if ((*it) == L'\n' || (*it) == L'\t')
+                       (*it) = L' ';   
+}
+
+
+void Text::forOutliner(docstring & os, size_t const maxlen,
+                                          bool const shorten) const
 {
-       LASSERT(maxlen >= 8, maxlen = TOC_ENTRY_LENGTH);
-       for (size_t i = 0; i != pars_.size() && os.length() < maxlen; ++i)
-               pars_[i].forOutliner(os, maxlen);
-       if (shorten && os.length() >= maxlen)
-               os = os.substr(0, maxlen - 3) + from_ascii("...");
+       size_t tmplen = shorten ? maxlen + 1 : maxlen;
+       for (size_t i = 0; i != pars_.size() && os.length() < tmplen; ++i)
+               pars_[i].forOutliner(os, tmplen, false);
+       if (shorten)
+               shortenForOutliner(os, maxlen);
 }