+ id_ = paragraph_id++;
+}
+
+
+bool Paragraph::Pimpl::isChanged(pos_type start, pos_type end) const
+{
+ BOOST_ASSERT(start >= 0 && start <= size());
+ BOOST_ASSERT(end > start && end <= size() + 1);
+
+ return changes_.isChanged(start, end);
+}
+
+
+void Paragraph::Pimpl::setChange(Change const & change)
+{
+ // beware of the imaginary end-of-par character!
+ changes_.set(change, 0, size() + 1);
+
+ /*
+ * Propagate the change recursively - but not in case of DELETED!
+ *
+ * Imagine that your co-author makes changes in an existing inset. He
+ * sends your document to you and you come to the conclusion that the
+ * inset should go completely. If you erase it, LyX must not delete all
+ * text within the inset. Otherwise, the change tracked insertions of
+ * your co-author get lost and there is no way to restore them later.
+ *
+ * Conclusion: An inset's content should remain untouched if you delete it
+ */
+
+ if (change.type != Change::DELETED) {
+ for (pos_type pos = 0; pos < size(); ++pos) {
+ if (owner_->isInset(pos)) {
+ owner_->getInset(pos)->setChange(change);
+ }
+ }
+ }