]> git.lyx.org Git - features.git/commitdiff
src/paragraph.h:
authorMichael Schmitt <michael.schmitt@teststep.org>
Mon, 8 May 2006 20:30:52 +0000 (20:30 +0000)
committerMichael Schmitt <michael.schmitt@teststep.org>
Mon, 8 May 2006 20:30:52 +0000 (20:30 +0000)
  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

src/changes.C
src/changes.h
src/lyxfind.C
src/lyxfunc.C
src/paragraph.C
src/paragraph.h
src/paragraph_funcs.C
src/paragraph_pimpl.C
src/paragraph_pimpl.h
src/rowpainter.C
src/text.C

index fd12f218fd05625e075413bf084a65128668b950..3d86ce666bee88ccb057a62f299dcfadb938ca9f 100644 (file)
@@ -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()) {
index 1777c8f09ab5c3a4430f8331a81ea8ca1211b005..dabfdf80e818293eeb4689fa6f23cc97677890e8 100644 (file)
@@ -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;
index e47110177f94166c23deab02a6d9bc0246e317d6..c54c36b1ec8f2e0a0c16f9b3609806174a68f329 100644 (file)
@@ -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;
index 783f356022184dde64d950e9c851fee62b0812b5..b690c7300c0910c2d0f38b6dc16af8b4c498ee12 100644 (file)
@@ -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;
                }
index 7fba24711d8904f20949fac75159e47bf586659f..34c4881cb854e1abdbf7fc9e77465ff0f1eeb94a 100644 (file)
@@ -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);
 }
 
 
index d8f1cd7a0045bd8177eb46fa00b99a10fd2e02f1..98e909257bf4379cb7e96242be33a099d19126c7 100644 (file)
@@ -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
index 053489e88adfb819b68e2bc03f48d98c82424994..252c5956dedf931a615ff4215406868fce48be21 100644 (file)
@@ -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;
        }
index 5e4bd220a36dd774e0458f6221661740d05bd1af..6e3c63cb5538af80d8be44c7e7ab40cbe96428db 100644 (file)
@@ -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
index f0780d4372c47f76dedb6c0cf3b81cd03422130a..f24c36dbf8ed1bcb2ed080baa9b0866422dc96a6 100644 (file)
@@ -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
index 18ab0232412839ca8d8faf0aef8b94a9f1a05f55..3945d80ae71b42819191a44b62cae84c6b53a796 100644 (file)
@@ -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;
index 1d87200dd2ab000e812d0bc5346fe68bdb47b12c..729c9cad0968a495218df3682f2b47eda05917b2 100644 (file)
@@ -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 =