]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphMetrics.C
* src/insets/insetcommand.C: fix plaintext() output
[lyx.git] / src / ParagraphMetrics.C
index 42f8d31c1e123ae9e4261d8aca499ab844762265..82c27b751c6d2f17128986bfa066b00d47bb19a1 100644 (file)
@@ -51,6 +51,7 @@
 #include "support/unicode.h"
 
 #include <boost/bind.hpp>
+#include <boost/crc.hpp>
 
 #include <algorithm>
 #include <list>
@@ -78,6 +79,42 @@ ParagraphMetrics::ParagraphMetrics(Paragraph const & par): par_(&par)
 }
 
 
+ParagraphMetrics & ParagraphMetrics::operator=(
+       ParagraphMetrics const & pm)
+{
+       rows_ = pm.rows_;
+       dim_ = pm.dim_;
+       par_ = pm.par_;
+       return *this;
+}
+
+
+size_type ParagraphMetrics::calculateRowSignature(Row const & row)
+{
+       boost::crc_32_type crc;
+       for (pos_type i = row.pos(); i < row.endpos(); ++i) {
+               char_type const b[] = { par_->getChar(i) };
+               crc.process_bytes(b, 1);
+       }
+       return crc.checksum();
+}
+
+
+void ParagraphMetrics::updateRowChangeStatus()
+{
+       size_t const size = rows_.size();
+       row_change_status_.resize(size);
+       row_signature_.resize(size);
+
+       for (size_t i = 0; i != size; ++i) {
+               // Row signature; has row changed since last update?
+               size_type const row_sig = calculateRowSignature(rows_[i]);
+               row_change_status_[i] = row_signature_[i] != row_sig;
+               row_signature_[i] = row_sig;
+       }
+}
+
+
 Row & ParagraphMetrics::getRow(pos_type pos, bool boundary)
 {
        BOOST_ASSERT(!rows().empty());