X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FParagraphMetrics.C;h=a0286839612ed00eafe91dd19f4a52b8f73b593a;hb=cd4b6edc73d56976611a29da5b133ed322f44997;hp=42f8d31c1e123ae9e4261d8aca499ab844762265;hpb=b2126408cfeaa251bc966e3df49a7000a202add3;p=lyx.git diff --git a/src/ParagraphMetrics.C b/src/ParagraphMetrics.C index 42f8d31c1e..a028683961 100644 --- a/src/ParagraphMetrics.C +++ b/src/ParagraphMetrics.C @@ -32,7 +32,6 @@ #include "lyxrow.h" #include "outputparams.h" #include "paragraph_funcs.h" -#include "ParagraphList_fwd.h" #include "rowpainter.h" @@ -51,6 +50,7 @@ #include "support/unicode.h" #include +#include #include #include @@ -78,6 +78,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());