X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTexRow.cpp;h=4e23cf7641b8834dbefae7a03e2c6553f1247bd6;hb=d3c63f97c4fce4e091277ced6c1829473c311231;hp=4bec66e05af69a8c7cbfe1b1bfde51334324a2e6;hpb=f4f68a57649d4362039a7779b49b65fc557e5bff;p=lyx.git diff --git a/src/TexRow.cpp b/src/TexRow.cpp index 4bec66e05a..4e23cf7641 100644 --- a/src/TexRow.cpp +++ b/src/TexRow.cpp @@ -35,8 +35,11 @@ bool TexRow::RowEntryList::addEntry(RowEntry const & entry) if (!entry.is_math) { if (text_entry_ < size()) return false; - else + else { text_entry_ = size(); + push_back(RowEntry(entry)); + return true; + } } forceAddEntry(entry); return true; @@ -50,7 +53,7 @@ void TexRow::RowEntryList::forceAddEntry(RowEntry const & entry) } -TexRow::TextEntry TexRow::RowEntryList::getTextEntry() const +TextEntry TexRow::RowEntryList::getTextEntry() const { if (text_entry_ < size()) return operator[](text_entry_).text; @@ -58,7 +61,7 @@ TexRow::TextEntry TexRow::RowEntryList::getTextEntry() const } -TexRow::RowEntry TexRow::RowEntryList::entry() const +RowEntry TexRow::RowEntryList::entry() const { if (0 < size()) return operator[](0); @@ -74,8 +77,8 @@ void TexRow::RowEntryList::append(RowEntryList const & row) } -TexRow::TextEntry const TexRow::text_none = { -1, 0 }; -TexRow::RowEntry const TexRow::row_none = { false, TexRow::text_none }; +TextEntry const TexRow::text_none = { -1, 0 }; +RowEntry const TexRow::row_none = { false, { TexRow::text_none } }; bool TexRow::isNone(TextEntry const & t) @@ -98,7 +101,7 @@ void TexRow::reset(bool enable) } -TexRow::RowEntry TexRow::textEntry(int id, int pos) +RowEntry TexRow::textEntry(int id, int pos) { RowEntry entry; entry.is_math = false; @@ -108,7 +111,7 @@ TexRow::RowEntry TexRow::textEntry(int id, int pos) } -TexRow::RowEntry TexRow::mathEntry(uid_type id, idx_type cell) +RowEntry TexRow::mathEntry(uid_type id, idx_type cell) { RowEntry entry; entry.is_math = true; @@ -118,8 +121,8 @@ TexRow::RowEntry TexRow::mathEntry(uid_type id, idx_type cell) } -bool operator==(TexRow::RowEntry const & entry1, - TexRow::RowEntry const & entry2) +bool operator==(RowEntry const & entry1, + RowEntry const & entry2) { return entry1.is_math == entry2.is_math && (entry1.is_math @@ -204,19 +207,16 @@ void TexRow::append(TexRow const & texrow) bool TexRow::getIdFromRow(int row, int & id, int & pos) const { TextEntry t = text_none; - bool ret = false; if (row <= int(rowlist_.size())) while (row > 0 && isNone(t = rowlist_[row - 1].getTextEntry())) --row; - if (row > 0) - ret = true; id = t.id; pos = t.pos; - return ret; + return !isNone(t); } -TexRow::RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice) +RowEntry TexRow::rowEntryFromCursorSlice(CursorSlice const & slice) { RowEntry entry; InsetMath * insetMath = slice.asInsetMath(); @@ -408,7 +408,7 @@ std::pair TexRow::rowFromDocIterator(DocIterator const & dit) const // matches either at a deeper level, or at the same level but not // before. for (size_t i = best_slice; i < n; ++i) { - TexRow::RowEntry entry_i = rowEntryFromCursorSlice(dit[i]); + RowEntry entry_i = rowEntryFromCursorSlice(dit[i]); if (sameParOrInsetMath(*it, entry_i)) { if (comparePos(*it, entry_i) >= 0 && (i > best_slice @@ -478,7 +478,7 @@ docstring TexRow::asString(RowEntry const & entry) ///prepends the texrow to the source given by tex, for debugging purpose void TexRow::prepend(docstring_list & tex) const { - int const prefix_length = 25; + size_type const prefix_length = 25; if (tex.size() < rowlist_.size()) tex.resize(rowlist_.size()); std::vector::const_iterator it = rowlist_.begin(); @@ -492,7 +492,7 @@ void TexRow::prepend(docstring_list & tex) const entry += asString(*it2); if (entry.length() < prefix_length) entry = entry + docstring(prefix_length - entry.length(), L' '); - int i = it - beg; + ptrdiff_t i = it - beg; tex[i] = entry + " " + tex[i]; } }