- // This is in the critical path for loading!
- pos_type const siz = size();
- lyx::Assert(pos <= siz);
- // This is stronger, and I belive that this is the assertion
- // that we should really use. (Lgb)
- //Assert(pos < size());
-
- // Then this has no meaning. (Lgb)
- if (!siz || pos == siz)
- return '\0';
-
- return text[pos];
+ BOOST_ASSERT(start >= 0 && start <= size());
+ BOOST_ASSERT(end > start && end <= size() + 1);
+
+ for (pos_type pos = start; pos < end; ++pos) {
+ switch (lookupChange(pos).type) {
+ case Change::UNCHANGED:
+ break;
+
+ case Change::INSERTED:
+ changes_.set(Change(Change::UNCHANGED), pos);
+ break;
+
+ case Change::DELETED:
+ // Suppress access to non-existent
+ // "end-of-paragraph char"
+ if (pos < size()) {
+ eraseChar(pos, false);
+ --end;
+ --pos;
+ }
+ break;
+ }
+
+ // also accept changes in nested insets
+ if (pos < size() && owner_->isInset(pos)) {
+ owner_->getInset(pos)->acceptChanges();
+ }
+ }
+}
+
+
+void Paragraph::Pimpl::rejectChanges(pos_type start, pos_type end)
+{
+ BOOST_ASSERT(start >= 0 && start <= size());
+ BOOST_ASSERT(end > start && end <= size() + 1);
+
+ for (pos_type pos = start; pos < end; ++pos) {
+ switch (lookupChange(pos).type) {
+ case Change::UNCHANGED:
+ // also reject changes inside of insets
+ if (pos < size() && owner_->isInset(pos)) {
+ owner_->getInset(pos)->rejectChanges();
+ }
+ break;
+
+ case Change::INSERTED:
+ // Suppress access to non-existent
+ // "end-of-paragraph char"
+ if (pos < size()) {
+ eraseChar(pos, false);
+ --end;
+ --pos;
+ }
+ break;
+
+ case Change::DELETED:
+ changes_.set(Change(Change::UNCHANGED), pos);
+
+ // Do NOT reject changes within a deleted inset!
+ // There may be insertions of a co-author inside of it!
+
+ break;
+ }
+ }