<< "\\lyxformat " << LYX_FORMAT << "\n"
<< "\\begin_document\n";
-
/// For each author, set 'used' to true if there is a change
/// by this author in the document; otherwise set it to 'false'.
AuthorList::Authors::const_iterator a_it = params().authors().begin();
for (; a_it != a_end; ++a_it)
a_it->second.setUsed(false);
- ParIterator const end = par_iterator_end();
- ParIterator it = par_iterator_begin();
+ ParIterator const end = const_cast<Buffer *>(this)->par_iterator_end();
+ ParIterator it = const_cast<Buffer *>(this)->par_iterator_begin();
for ( ; it != end; ++it)
it->checkAuthors(params().authors());
}
-ParIterator Buffer::getParFromID(int const id) const
+ParConstIterator Buffer::getParFromID(int const id) const
{
ParConstIterator it = par_iterator_begin();
ParConstIterator const end = par_iterator_end();
}
+ParIterator Buffer::getParFromID(int const id)
+{
+ ParIterator it = par_iterator_begin();
+ ParIterator const end = par_iterator_end();
+
+ if (id < 0) {
+ // John says this is called with id == -1 from undo
+ lyxerr << "getParFromID(), id: " << id << endl;
+ return end;
+ }
+
+ for (; it != end; ++it)
+ if (it->id() == id)
+ return it;
+
+ return end;
+}
+
+
bool Buffer::hasParWithID(int const id) const
{
ParConstIterator const it = getParFromID(id);
void Buffer::updateMacroInstances() const
{
- LYXERR(Debug::MACROS, "updateMacroInstances for " << d->filename.onlyFileName());
- ParIterator it = par_iterator_begin();
- ParIterator end = par_iterator_end();
+ LYXERR(Debug::MACROS, "updateMacroInstances for "
+ << d->filename.onlyFileName());
+ ParConstIterator it = par_iterator_begin();
+ ParConstIterator end = par_iterator_end();
for (; it != end; it.forwardPos()) {
// look for MathData cells in InsetMathNest insets
Inset * inset = it.nextInset();
pit_type &, pos_type &,
Font const &, docstring const &, bool);
///
- ParIterator getParFromID(int id) const;
+ ParIterator getParFromID(int id);
+ ///
+ ParConstIterator getParFromID(int id) const;
/// do we have a paragraph with this id?
bool hasParWithID(int id) const;
#include <config.h>
#include "Bidi.h"
-#include "BufferView.h"
#include "Buffer.h"
-#include "Cursor.h"
+#include "BufferView.h"
#include "CoordCache.h"
+#include "Cursor.h"
#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "Encoding.h"
+#include "Font.h"
#include "FuncRequest.h"
#include "Language.h"
#include "lfuns.h"
-#include "Font.h"
#include "LyXFunc.h" // only for setMessage()
#include "LyXRC.h"
-#include "Row.h"
-#include "Text.h"
-#include "Paragraph.h"
#include "paragraph_funcs.h"
+#include "Paragraph.h"
#include "ParIterator.h"
+#include "Row.h"
+#include "Text.h"
#include "TextMetrics.h"
+#include "TocBackend.h"
#include "support/debug.h"
#include "support/docstream.h"
}
+void Cursor::checkBufferStructure()
+{
+ if (paragraph().layout()->toclevel == Layout::NOT_IN_TOC)
+ return;
+ Buffer const * master = buffer().masterBuffer();
+ master->tocBackend().updateItem(ParConstIterator(*this));
+ master->structureChanged();
+}
+
+
} // namespace lyx
/// Convenience: prepare undo for the selected paragraphs
void recordUndoSelection();
+ ///
+ void checkBufferStructure();
+
public:
///
BufferView * bv_;
}
-bool operator==(ParIterator const & iter1, ParIterator const & iter2)
-{
- return DocIterator(iter1) == DocIterator(iter2);
-}
-
-
-bool operator!=(ParIterator const & iter1, ParIterator const & iter2)
-{
- return !(iter1 == iter2);
-}
-
-
DocIterator makeDocIterator(ParIterator const & par, pos_type pos)
{
DocIterator dit(par);
return text()->paragraphs();
}
-
+#if 0
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
{
+ // FIXME: this makes two full copies!
return DocIterator(iter1) == DocIterator(iter2);
}
{
return !(iter1 == iter2);
}
+#endif
// FIXME: const correctness!
///
ParIterator(ParIterator const &);
///
- ParIterator(DocIterator const &);
+ explicit ParIterator(DocIterator const &);
/// This really should be implemented...
//ParIterator & operator=(ParIterator const &);
///
-bool operator==(ParIterator const & iter1, ParIterator const & iter2);
+//bool operator==(ParIterator const & it1, ParIterator const & it2);
-// FIXME: Unfortunately operator!=(ParIterator &, ParIterator &) is implemented with
-// operator!=(DocIterator &, DocIterator &) that gives false if the positions
-// are different, even if the pars are the same. So ultimately it's a bug in
-// operator!=(ParIterator &, ParIterator &) I'd say (nevertheless, I would be
-// reluctant to change it, because I fear that some part of the code could rely on
-// this "bug". --Alfredo
-bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
+// FIXME: Unfortunately operator!=(ParIterator &, ParIterator &) is
+// implemented with operator!=(DocIterator &, DocIterator &) that gives
+// false if the positions are different, even if the pars are the same.
+// So ultimately it's a bug in operator!=(ParIterator &, ParIterator &)
+// I'd say (nevertheless, I would be reluctant to change it, because I
+// fear that some part of the code could rely on this "bug". --Alfredo
+//bool operator!=(ParIterator const & it1, ParIterator const & it2);
class ParConstIterator : public std::iterator<std::forward_iterator_tag,
{
public:
///
- ParConstIterator(): DocIterator() {}
+ ParConstIterator() : DocIterator() {}
///
ParConstIterator(ParConstIterator const &);
///
- ParConstIterator(DocIterator const &);
+ explicit ParConstIterator(DocIterator const &);
///
ParConstIterator & operator++();
ParagraphList const & plist() const;
};
-bool operator==(ParConstIterator const & iter1,
- ParConstIterator const & iter2);
+//bool operator==(ParConstIterator const & it1, ParConstIterator const & it2);
-bool operator!=(ParConstIterator const & iter1,
- ParConstIterator const & iter2);
+//bool operator!=(ParConstIterator const & it1, ParConstIterator const & it2);
ParConstIterator par_const_iterator_begin(Inset const & inset);
}
-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;
}
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);
}
}
par.insertChar(cur.pos(), c, cur.current_font, cur.buffer().params().trackChanges);
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
// cur.updateFlags(Update::Force);
setCursor(cur.top(), cur.pit(), cur.pos() + 1);
cursorForwardOneWord(cur);
cur.setSelection();
cutSelection(cur, true, false);
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
}
}
cursorBackwardOneWord(cur);
cur.setSelection();
cutSelection(cur, true, false);
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
}
}
setCursor(cur, endPit, right);
cur.setSelection();
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
}
// the character has been logically deleted only => skip it
cur.top().forwardPos();
}
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
needsUpdate = true;
} else {
if (cur.pit() == cur.lastpit())
// Make sure the cursor is correct. Is this really needed?
// No, not really... at least not here!
cur.text()->setCursor(cur.top(), cur.pit(), cur.pos());
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
}
return needsUpdate;
setCursorIntern(cur, cur.pit(), cur.pos() - 1,
false, cur.boundary());
cur.paragraph().eraseChar(cur.pos(), cur.buffer().params().trackChanges);
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
}
if (cur.pos() == cur.lastpos())
par.insertChar(pos1, char2, font2, trackChanges);
par.insertChar(pos2, char1, font1, trackChanges);
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
// After the transposition, move cursor to after the transposition.
setCursor(cur, cur.pit(), pos2);
text_->deleteWordForward(cur);
else
cap::cutSelection(cur, true, false);
- checkBufferStructure(cur.buffer(), cur);
+ cur.checkBufferStructure();
}
}
}
-void checkBufferStructure(Buffer & buffer, ParIterator const & par_it)
-{
- if (par_it->layout()->toclevel != Layout::NOT_IN_TOC) {
- Buffer const * master = buffer.masterBuffer();
- master->tocBackend().updateItem(par_it);
- master->structureChanged();
- }
-}
-
-
} // namespace lyx
///
void updateLabels(Buffer const &, ParIterator &);
-///
-void checkBufferStructure(Buffer &, ParIterator const &);
-
} // namespace lyx
#endif // BUFFER_FUNCS_H