From: Michael Schmitt Date: Mon, 8 May 2006 20:30:52 +0000 (+0000) Subject: src/paragraph.h: X-Git-Tag: 1.6.10~13248 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=10c8081a541e07db24d10ef5df376a5bcbdc15db;p=features.git src/paragraph.h: remove lookupChangeType; rename setChange to setChangeType; rename setChangeFull to setChange src/paragraph_pimpl.h: remove lookupChange; rename lookupChangeFull to lookupChange; rename setChange to setChangeType; rename setChangeFull to setChange src/changes.h: remove lookup; rename lookupFull to lookup; rename loose_contains to containsOrPrecedes; adjust the other files accordingly git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13812 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/changes.C b/src/changes.C index fd12f218fd..3d86ce666b 100644 --- a/src/changes.C +++ b/src/changes.C @@ -66,7 +66,7 @@ bool Changes::Range::contains(pos_type const pos) const } -bool Changes::Range::loose_contains(pos_type const pos) const +bool Changes::Range::containsOrPrecedes(pos_type const pos) const { return pos >= start && pos <= end; } @@ -274,7 +274,7 @@ void Changes::del(Change const change, ChangeTable::size_type const pos) erase(pos); } break; - } else if (range.loose_contains(pos) && it + 1 == table_.end()) { + } else if (range.containsOrPrecedes(pos) && it + 1 == table_.end()) { // this case happens when building from .lyx set(change, pos); break; @@ -293,7 +293,7 @@ void Changes::add(Change const change, ChangeTable::size_type const pos) for (; it != end; ++it) { Range & range(it->range); - if (!found && range.loose_contains(pos)) { + if (!found && range.containsOrPrecedes(pos)) { found = true; if (lyxerr.debugging(Debug::CHANGES)) { lyxerr[Debug::CHANGES] << "Found range of " @@ -312,7 +312,7 @@ void Changes::add(Change const change, ChangeTable::size_type const pos) } -Change const Changes::lookupFull(pos_type const pos) const +Change const Changes::lookup(pos_type const pos) const { if (!table_.size()) { if (lyxerr.debugging(Debug::CHANGES)) @@ -334,28 +334,6 @@ Change const Changes::lookupFull(pos_type const pos) const } -Change::Type Changes::lookup(pos_type const pos) const -{ - if (!table_.size()) { - if (lyxerr.debugging(Debug::CHANGES)) - lyxerr[Debug::CHANGES] << "Empty, type is " << empty_type_ << endl; - return empty_type_; - } - - ChangeTable::const_iterator it = table_.begin(); - ChangeTable::const_iterator end = table_.end(); - - for (; it != end; ++it) { - if (it->range.contains(pos)) - return it->change.type; - } - - check(); - BOOST_ASSERT(false && "missing changes for pos"); - return Change::UNCHANGED; -} - - bool Changes::isChange(pos_type const start, pos_type const end) const { if (!table_.size()) { diff --git a/src/changes.h b/src/changes.h index 1777c8f09a..dabfdf80e8 100644 --- a/src/changes.h +++ b/src/changes.h @@ -72,11 +72,8 @@ public: /// mark the given change and adjust void record(Change, lyx::pos_type pos); - /// return the change type at the given position - Change::Type lookup(lyx::pos_type pos) const; - /// return the change at the given position - Change const lookupFull(lyx::pos_type pos) const; + Change const lookup(lyx::pos_type pos) const; /// return true if there is a change in the given range bool isChange(lyx::pos_type start, lyx::pos_type end) const; @@ -110,7 +107,7 @@ private: bool contains(lyx::pos_type pos) const; // does this range contain pos, or can it be appended ? - bool loose_contains(lyx::pos_type pos) const; + bool containsOrPrecedes(lyx::pos_type pos) const; // is this range contained within r ? bool contained(Range const & r) const; diff --git a/src/lyxfind.C b/src/lyxfind.C index e47110177f..c54c36b1ec 100644 --- a/src/lyxfind.C +++ b/src/lyxfind.C @@ -128,7 +128,7 @@ bool findBackwards(DocIterator & cur, MatchString const & match) bool findChange(DocIterator & cur) { for (; cur; cur.forwardPos()) - if (cur.inTexted() && cur.paragraph().lookupChangeType(cur.pos()) + if (cur.inTexted() && cur.paragraph().lookupChange(cur.pos()).type != Change::UNCHANGED) return true; return false; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 783f356022..b690c7300c 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -191,7 +191,7 @@ Change::Type lookupChangeType(DocIterator const & dit, bool outer = false) CursorSlice const & slice = dit[i]; if (!slice.inset().inMathed() && slice.pos() < slice.paragraph().size()) { - Change::Type const ch = slice.paragraph().lookupChangeType(slice.pos()); + Change::Type const ch = slice.paragraph().lookupChange(slice.pos()).type; if (ch != Change::UNCHANGED) return ch; } diff --git a/src/paragraph.C b/src/paragraph.C index 7fba24711d..34c4881cb8 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -157,7 +157,7 @@ void Paragraph::write(Buffer const & buf, ostream & os, int column = 0; for (pos_type i = 0; i <= size(); ++i) { - Change change = pimpl_->lookupChangeFull(i); + Change change = pimpl_->lookupChange(i); Changes::lyxMarkChange(os, column, curtime, running_change, change); running_change = change; @@ -560,7 +560,7 @@ int Paragraph::stripLeadingSpaces() int i = 0; while (!empty() && (isNewline(0) || isLineSeparator(0)) - && (lookupChange(0) != Change::DELETED)) { + && (lookupChange(0).type != Change::DELETED)) { erase(0); ++i; } @@ -1001,7 +1001,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf, open_font = true; } - Change::Type change = pimpl_->lookupChange(i); + Change::Type change = pimpl_->lookupChange(i).type; column += Changes::latexMarkChange(os, running_change, change, output); @@ -1626,17 +1626,10 @@ void Paragraph::cleanChanges(ChangeTracking ct) } -Change::Type Paragraph::lookupChangeType(lyx::pos_type pos) const -{ - BOOST_ASSERT(pos <= size()); - return pimpl_->lookupChange(pos); -} - - Change const Paragraph::lookupChange(lyx::pos_type pos) const { BOOST_ASSERT(pos <= size()); - return pimpl_->lookupChangeFull(pos); + return pimpl_->lookupChange(pos); } @@ -1652,15 +1645,15 @@ bool Paragraph::isChangeEdited(pos_type start, pos_type end) const } -void Paragraph::setChange(lyx::pos_type pos, Change::Type type) +void Paragraph::setChangeType(lyx::pos_type pos, Change::Type type) { - pimpl_->setChange(pos, type); + pimpl_->setChangeType(pos, type); } -void Paragraph::setChangeFull(lyx::pos_type pos, Change change) +void Paragraph::setChange(lyx::pos_type pos, Change change) { - pimpl_->setChangeFull(pos, change); + pimpl_->setChange(pos, change); } diff --git a/src/paragraph.h b/src/paragraph.h index d8f1cd7a00..98e909257b 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -220,9 +220,6 @@ public: /// set entire paragraph to new text for change tracking void cleanChanges(ChangeTracking ct = trackingUnknown); - /// look up change type at given pos - Change::Type lookupChangeType(lyx::pos_type pos) const; - /// look up change at given pos Change const lookupChange(lyx::pos_type pos) const; @@ -232,11 +229,11 @@ public: /// is there a non-addition in this range ? bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const; - /// set change at pos - void setChange(lyx::pos_type pos, Change::Type type); + /// set change type at given pos + void setChangeType(lyx::pos_type pos, Change::Type type); - /// set full change at pos - void setChangeFull(lyx::pos_type pos, Change change); + /// set change at given pos + void setChange(lyx::pos_type pos, Change change); /// accept change void acceptChange(lyx::pos_type start, lyx::pos_type end); @@ -447,13 +444,13 @@ private: inline bool isInsertedText(Paragraph const & par, lyx::pos_type pos) { - return par.lookupChangeType(pos) == Change::INSERTED; + return par.lookupChange(pos).type == Change::INSERTED; } inline bool isDeletedText(Paragraph const & par, lyx::pos_type pos) { - return par.lookupChangeType(pos) == Change::DELETED; + return par.lookupChange(pos).type == Change::DELETED; } #endif // PARAGRAPH_H diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index 053489e88a..252c5956de 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -144,7 +144,7 @@ void breakParagraph(BufferParams const & bparams, pos_type pos_end = par.size() - 1; for (pos_type i = pos, j = pos; i <= pos_end; ++i) { - Change::Type change = par.lookupChangeType(i); + Change::Type change = par.lookupChange(i).type; if (moveItem(par, *tmp, bparams, i, j - pos)) { tmp->setChange(j - pos, change); ++j; @@ -212,12 +212,12 @@ void breakParagraphConservative(BufferParams const & bparams, pos_type pos_end = par.size() - 1; for (pos_type i = pos, j = pos; i <= pos_end; ++i) { - Change::Type change = par.lookupChangeType(i); + Change::Type change = par.lookupChange(i).type; if (moveItem(par, tmp, bparams, i, j - pos, change)) ++j; } // Move over end-of-par change attr - tmp.setChange(tmp.size(), par.lookupChangeType(par.size())); + tmp.setChange(tmp.size(), par.lookupChange(par.size()).type); // If tracking changes, set all the text that is to be // erased to Type::INSERTED. @@ -252,10 +252,10 @@ void mergeParagraph(BufferParams const & bparams, // forcibly to "black" prevents this scenario. -- MV 13.3.2006 par.setChange(par.size(), Change::UNCHANGED); - Change::Type cr = next.lookupChangeType(next.size()); + Change::Type cr = next.lookupChange(next.size()).type; // ok, now copy the paragraph for (pos_type i = 0, j = 0; i <= pos_end; ++i) { - Change::Type change = next.lookupChangeType(i); + Change::Type change = next.lookupChange(i).type; if (moveItem(next, par, bparams, i, pos_insert + j, change)) ++j; } diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 5e4bd220a3..6e3c63cb55 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -147,7 +147,7 @@ bool Paragraph::Pimpl::isChangeEdited(pos_type start, pos_type end) const } -void Paragraph::Pimpl::setChange(pos_type pos, Change::Type type) +void Paragraph::Pimpl::setChangeType(pos_type pos, Change::Type type) { if (!tracking()) return; @@ -156,7 +156,7 @@ void Paragraph::Pimpl::setChange(pos_type pos, Change::Type type) } -void Paragraph::Pimpl::setChangeFull(pos_type pos, Change change) +void Paragraph::Pimpl::setChange(pos_type pos, Change change) { if (!tracking()) return; @@ -164,21 +164,13 @@ void Paragraph::Pimpl::setChangeFull(pos_type pos, Change change) changes_->set(change, pos); } -Change::Type Paragraph::Pimpl::lookupChange(pos_type pos) const -{ - if (!tracking()) - return Change::UNCHANGED; - return changes_->lookup(pos); -} - - -Change const Paragraph::Pimpl::lookupChangeFull(pos_type pos) const +Change const Paragraph::Pimpl::lookupChange(pos_type pos) const { if (!tracking()) return Change(Change::UNCHANGED); - return changes_->lookupFull(pos); + return changes_->lookup(pos); } @@ -212,7 +204,7 @@ void Paragraph::Pimpl::acceptChange(pos_type start, pos_type end) pos_type i = start; for (; i < end; ++i) { - switch (lookupChange(i)) { + switch (lookupChange(i).type) { case Change::UNCHANGED: break; @@ -251,7 +243,7 @@ void Paragraph::Pimpl::rejectChange(pos_type start, pos_type end) pos_type i = start; for (; i < end; ++i) { - switch (lookupChange(i)) { + switch (lookupChange(i).type) { case Change::UNCHANGED: break; @@ -378,7 +370,7 @@ bool Paragraph::Pimpl::erase(pos_type pos) BOOST_ASSERT(pos <= size()); if (tracking()) { - Change::Type changetype(changes_->lookup(pos)); + Change::Type changetype(changes_->lookup(pos).type); changes_->record(Change(Change::DELETED), pos); // only allow the actual removal if it was /new/ text diff --git a/src/paragraph_pimpl.h b/src/paragraph_pimpl.h index f0780d4372..f24c36dbf8 100644 --- a/src/paragraph_pimpl.h +++ b/src/paragraph_pimpl.h @@ -44,18 +44,16 @@ public: void untrackChanges(); /// set all text as new for change mode void cleanChanges(Paragraph::ChangeTracking ct = Paragraph::trackingUnknown); - /// look up change type at given pos - Change::Type lookupChange(lyx::pos_type pos) const; /// look up change at given pos - Change const lookupChangeFull(lyx::pos_type pos) const; - /// is there a change in the given range ? + Change const lookupChange(lyx::pos_type pos) const; + /// is there a change within the given range ? bool isChanged(lyx::pos_type start, lyx::pos_type end) const; /// is there a non-addition in this range ? bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const; - /// set change at pos - void setChange(lyx::pos_type pos, Change::Type type); - /// set full change at pos - void setChangeFull(lyx::pos_type pos, Change change); + /// set change type at given pos + void setChangeType(lyx::pos_type pos, Change::Type type); + /// set change at given pos + void setChange(lyx::pos_type pos, Change change); /// mark as erased void markErased(bool); /// accept change diff --git a/src/rowpainter.C b/src/rowpainter.C index 18ab023241..3945d80ae7 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -250,7 +250,7 @@ void RowPainter::paintChars(pos_type & vpos, LyXFont font, pos_type pos = text_.bidi.vis2log(vpos); pos_type const end = row_.endpos(); FontSpan const font_span = par_.fontSpan(pos); - Change::Type const prev_change = par_.lookupChangeType(pos); + Change::Type const prev_change = par_.lookupChange(pos).type; // first character string str; diff --git a/src/text.C b/src/text.C index 1d87200dd2..729c9cad09 100644 --- a/src/text.C +++ b/src/text.C @@ -380,7 +380,7 @@ void readParagraph(Buffer const & buf, Paragraph & par, LyXLex & lex) } } // Final change goes to paragraph break: - par.setChangeFull(par.size(), change); + par.setChange(par.size(), change); // Initialize begin_of_body_ on load; redoParagraph maintains par.setBeginOfBody(); @@ -1411,7 +1411,7 @@ void LyXText::acceptChange(LCursor & cur) DocIterator it = cur.selectionBegin(); DocIterator et = cur.selectionEnd(); pit_type pit = it.pit(); - Change::Type const type = pars_[pit].lookupChangeType(it.pos()); + Change::Type const type = pars_[pit].lookupChange(it.pos()).type; for (; pit <= et.pit(); ++pit) { pos_type left = ( pit == it.pit() ? it.pos() : 0 ); pos_type right = @@ -1448,7 +1448,7 @@ void LyXText::rejectChange(LCursor & cur) DocIterator it = cur.selectionBegin(); DocIterator et = cur.selectionEnd(); pit_type pit = it.pit(); - Change::Type const type = pars_[pit].lookupChangeType(it.pos()); + Change::Type const type = pars_[pit].lookupChange(it.pos()).type; for (; pit <= et.pit(); ++pit) { pos_type left = ( pit == it.pit() ? it.pos() : 0 ); pos_type right =