From b55f70432cc95b3eadbb8c1deedfc6b819db47ab Mon Sep 17 00:00:00 2001 From: Michael Schmitt Date: Thu, 19 Oct 2006 12:49:11 +0000 Subject: [PATCH] Change tracking: src/paragraph.h: remove obsolete isChangeEdited(...); remove obsolete isInsertedText(...); turn isDeletedText(...) into Paragraph::isDeleted(...) src/paragraph_pimpl.h: remove obsolete isChangeEdited(...) src/changes.h: remove obsolete isChangeEdited(...) src/insets/insetert.C: src/paragraph_pimpl.C: src/frontends/controllers/ControlSpellchecker.C: src/rowpainter.C: src/changes.C: src/paragraph.C: src/buffer_funcs.C: adjust properly git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15371 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/buffer_funcs.C | 2 +- src/changes.C | 22 ------------------ src/changes.h | 3 --- .../controllers/ControlSpellchecker.C | 2 +- src/insets/insetert.C | 2 +- src/paragraph.C | 6 ----- src/paragraph.h | 23 +++++-------------- src/paragraph_pimpl.C | 10 +------- src/paragraph_pimpl.h | 2 -- src/rowpainter.C | 4 ++-- 10 files changed, 12 insertions(+), 64 deletions(-) diff --git a/src/buffer_funcs.C b/src/buffer_funcs.C index 706f0ccf81..573c77a726 100644 --- a/src/buffer_funcs.C +++ b/src/buffer_funcs.C @@ -260,7 +260,7 @@ int countWords(DocIterator const & from, DocIterator const & to) if (dit.inTexted() && dit.pos() != dit.lastpos() && dit.paragraph().isLetter(dit.pos()) - && !isDeletedText(dit.paragraph(), dit.pos())) { + && !dit.paragraph().isDeleted(dit.pos())) { if (!inword) { ++count; inword = true; diff --git a/src/changes.C b/src/changes.C index f3173bec95..3f688d827d 100644 --- a/src/changes.C +++ b/src/changes.C @@ -368,28 +368,6 @@ bool Changes::isChange(pos_type const start, pos_type const end) const } -bool Changes::isChangeEdited(lyx::pos_type const start, - lyx::pos_type const end) const -{ - if (!table_.size()) { - if (lyxerr.debugging(Debug::CHANGES)) - lyxerr[Debug::CHANGES] << "Empty, type is " << empty_type_ << endl; - return empty_type_ != Change::INSERTED; - } - - ChangeTable::const_iterator it = table_.begin(); - ChangeTable::const_iterator const itend = table_.end(); - - for (; it != itend; ++it) { - if (it->range.intersects(Range(start, end ? end - 1 : 0)) - && it->change.type != Change::INSERTED) { - return true; - } - } - return false; -} - - void Changes::merge() { if (lyxerr.debugging(Debug::CHANGES)) diff --git a/src/changes.h b/src/changes.h index 144a1abce9..9ef77e03c7 100644 --- a/src/changes.h +++ b/src/changes.h @@ -78,9 +78,6 @@ public: /// return true if there is a change in the given range bool isChange(lyx::pos_type start, lyx::pos_type end) const; - /// return true if there is a deleted or unchanged range contained - bool isChangeEdited(lyx::pos_type start, lyx::pos_type end) const; - /// remove the given entry. This implies that a character was /// deleted at pos, and will adjust all range bounds past it void erase(lyx::pos_type pos); diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 964773abee..3a3a9118dc 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -139,7 +139,7 @@ bool isLetter(DocIterator const & dit) // We want to pass the ' and escape chars to ispell || contains(lyx::from_utf8(lyxrc.isp_esc_chars + '\''), dit.paragraph().getChar(dit.pos()))) - && !isDeletedText(dit.paragraph(), dit.pos()); + && !dit.paragraph().isDeleted(dit.pos()); } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 32358d130d..4bc0275f61 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -154,7 +154,7 @@ int InsetERT::latex(Buffer const &, ostream & os, pos_type siz = par->size(); for (pos_type i = 0; i < siz; ++i) { // ignore all struck out text - if (isDeletedText(*par, i)) + if (par->isDeleted(i)) continue; os << par->getChar(i); diff --git a/src/paragraph.C b/src/paragraph.C index 62657139d5..4b4acea413 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1434,12 +1434,6 @@ bool Paragraph::isChanged(pos_type start, pos_type end) const } -bool Paragraph::isChangeEdited(pos_type start, pos_type end) const -{ - return pimpl_->isChangeEdited(start, end); -} - - void Paragraph::setChange(Change const & change) { pimpl_->setChange(change); diff --git a/src/paragraph.h b/src/paragraph.h index b09786d294..41238d081c 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -200,9 +200,10 @@ public: /// 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; + /// is there a deletion at the given pos ? + bool isDeleted(lyx::pos_type pos) const { + return lookupChange(pos).type == Change::DELETED; + } /// set change type at given pos void setChangeType(lyx::pos_type pos, Change::Type type); @@ -321,8 +322,8 @@ public: /// bool isHfill(lyx::pos_type pos) const { - return isInset(pos) - && getInset(pos)->lyxCode() == InsetBase::HFILL_CODE; + return isInset(pos) + && getInset(pos)->lyxCode() == InsetBase::HFILL_CODE; } /// hinted by profiler bool isInset(lyx::pos_type pos) const { @@ -415,16 +416,4 @@ private: Pimpl * pimpl_; }; - -inline bool isInsertedText(Paragraph const & par, lyx::pos_type pos) -{ - return par.lookupChange(pos).type == Change::INSERTED; -} - - -inline bool isDeletedText(Paragraph const & par, lyx::pos_type pos) -{ - return par.lookupChange(pos).type == Change::DELETED; -} - #endif // PARAGRAPH_H diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 795eae90d4..0ec8b4c620 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -92,6 +92,7 @@ void Paragraph::Pimpl::setContentsFromPar(Paragraph const & par) bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const { + // FIXME: change tracking (MG) if (!tracking()) return false; @@ -99,15 +100,6 @@ bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const } -bool Paragraph::Pimpl::isChangeEdited(pos_type start, pos_type end) const -{ - if (!tracking()) - return false; - - return changes_->isChangeEdited(start, end); -} - - void Paragraph::Pimpl::setChange(Change const & change) { // FIXME: change tracking (MG) diff --git a/src/paragraph_pimpl.h b/src/paragraph_pimpl.h index 7c91142cbe..9c971d413f 100644 --- a/src/paragraph_pimpl.h +++ b/src/paragraph_pimpl.h @@ -42,8 +42,6 @@ public: 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 for the entire par void setChange(Change const & change); /// set change type at given pos diff --git a/src/rowpainter.C b/src/rowpainter.C index ac58297801..204d5fd404 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -173,7 +173,7 @@ void RowPainter::paintInset(pos_type const pos, LyXFont const & font) bv_.buffer()->params().getFont() : font; pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0); - pi.erased_ = erased_ || isDeletedText(par_, pos); + pi.erased_ = erased_ || par_.isDeleted(pos); bv_.coordCache().insets().add(inset, int(x_), yo_); InsetText const * const in = inset->asTextInset(); // non-wide insets are painted completely. Recursive @@ -688,7 +688,7 @@ void RowPainter::paintText() continue; } - is_struckout = isDeletedText(par_, pos); + is_struckout = par_.isDeleted(pos); if (is_struckout && !running_strikeout) { running_strikeout = true; -- 2.39.2