From a40d6cd7bcbf9a9ce3c0d5a0088455a34af0928d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 28 Aug 2007 22:44:09 +0000 Subject: [PATCH] Take Track-Change into account when calculating row signature. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19876 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ParagraphMetrics.cpp | 12 +++++++++--- src/ParagraphMetrics.h | 4 ++-- src/TextMetrics.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp index 7786de5a66..0fd4838d25 100644 --- a/src/ParagraphMetrics.cpp +++ b/src/ParagraphMetrics.cpp @@ -94,18 +94,24 @@ void ParagraphMetrics::reset(Paragraph const & par) } -size_type ParagraphMetrics::calculateRowSignature(Row const & row) +size_type ParagraphMetrics::calculateRowSignature(Row const & row, + BufferParams const & bparams) { 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); + if (bparams.trackChanges) { + Change change = par_->lookupChange(i); + char_type const b[] = { change.type }; + crc.process_bytes(b, 1); + } } return crc.checksum(); } -void ParagraphMetrics::updateRowChangeStatus() +void ParagraphMetrics::updateRowChangeStatus(BufferParams const & bparams) { size_t const size = rows_.size(); row_change_status_.resize(size); @@ -113,7 +119,7 @@ void ParagraphMetrics::updateRowChangeStatus() for (size_t i = 0; i != size; ++i) { // Row signature; has row changed since last update? - size_type const row_sig = calculateRowSignature(rows_[i]); + size_type const row_sig = calculateRowSignature(rows_[i], bparams); row_change_status_[i] = row_signature_[i] != row_sig; row_signature_[i] = row_sig; } diff --git a/src/ParagraphMetrics.h b/src/ParagraphMetrics.h index 261f0057a3..096c87a5e1 100644 --- a/src/ParagraphMetrics.h +++ b/src/ParagraphMetrics.h @@ -73,7 +73,7 @@ public: std::vector const & rowChangeStatus() const { return row_change_status_; } /// - void updateRowChangeStatus(); + void updateRowChangeStatus(BufferParams const & bparams); /// int rightMargin(Buffer const & buffer) const; /// @@ -86,7 +86,7 @@ private: /// typedef std::vector RowSignature; /// - size_type calculateRowSignature(Row const &); + size_type calculateRowSignature(Row const &, BufferParams const & bparams); /// mutable RowList rows_; /// diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 7ed1a00ca7..a8d5ab8754 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -268,7 +268,7 @@ bool TextMetrics::redoParagraph(pit_type const pit) // Update the row change statuses. The painter will need that info // in order to know which row has to be repainted. - pm.updateRowChangeStatus(); + pm.updateRowChangeStatus(bv_->buffer().params()); return changed; }