X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraph.cpp;h=4f4d9ff5630454a6e255d9183443a39fdf8786b7;hb=1acedf11da79f509da706bc8d6d2f491c9676087;hp=498c5c1c2c1eda23071bf0a826c66b300e612a86;hpb=9e5eebc14cd06f58000a4bd1903f157b65a3ab19;p=lyx.git diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 498c5c1c2c..4f4d9ff563 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -53,7 +53,6 @@ #include "support/lstrings.h" #include "support/Messages.h" #include "support/textutils.h" -#include "support/unicode.h" #include #include @@ -250,15 +249,13 @@ bool Paragraph::isChanged(pos_type start, pos_type end) const } -bool Paragraph::isMergedOnEndOfParDeletion(bool trackChanges) const { +bool Paragraph::isMergedOnEndOfParDeletion(bool trackChanges) const +{ // keep the logic here in sync with the logic of eraseChars() - - if (!trackChanges) { + if (!trackChanges) return true; - } - - Change change = d->changes_.lookup(size()); + Change const change = d->changes_.lookup(size()); return change.type == Change::INSERTED && change.author == 0; } @@ -292,22 +289,17 @@ void Paragraph::setChange(Change const & change) void Paragraph::setChange(pos_type pos, Change const & change) { BOOST_ASSERT(pos >= 0 && pos <= size()); - d->changes_.set(change, pos); // see comment in setChange(Change const &) above - - if (change.type != Change::DELETED && - pos < size() && isInset(pos)) { + if (change.type != Change::DELETED && pos < size() && isInset(pos)) getInset(pos)->setChange(change); - } } Change const & Paragraph::lookupChange(pos_type pos) const { BOOST_ASSERT(pos >= 0 && pos <= size()); - return d->changes_.lookup(pos); } @@ -1165,11 +1157,9 @@ void Paragraph::write(Buffer const & buf, ostream & os, } // this check is to amend a bug. LyX sometimes // inserts '\0' this could cause problems. - if (c != '\0') { - vector tmp = ucs4_to_utf8(c); - tmp.push_back('\0'); - os << &tmp[0]; - } else + if (c != '\0') + os << to_utf8(docstring(1, c)); + else lyxerr << "ERROR (Paragraph::writeFile):" " NULL char in structure." << endl; ++column; @@ -2224,15 +2214,13 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, bool Paragraph::isHfill(pos_type pos) const { - return isInset(pos) - && getInset(pos)->lyxCode() == HFILL_CODE; + return isInset(pos) && getInset(pos)->lyxCode() == HFILL_CODE; } bool Paragraph::isNewline(pos_type pos) const { - return isInset(pos) - && getInset(pos)->lyxCode() == NEWLINE_CODE; + return isInset(pos) && getInset(pos)->lyxCode() == NEWLINE_CODE; } @@ -2250,10 +2238,8 @@ bool Paragraph::isLetter(pos_type pos) const { if (isInset(pos)) return getInset(pos)->isLetter(); - else { - char_type const c = d->text_[pos]; - return isLetterChar(c) || isDigit(c); - } + char_type const c = d->text_[pos]; + return isLetterChar(c) || isDigit(c); } @@ -2366,8 +2352,7 @@ Inset * Paragraph::inInset() const InsetCode Paragraph::ownerCode() const { - return d->inset_owner_ ? - d->inset_owner_->lyxCode() : NO_CODE; + return d->inset_owner_ ? d->inset_owner_->lyxCode() : NO_CODE; }