From 65b3790153aa39d9dbcdf7ce6c24125607a580a7 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 19 Oct 2007 15:30:54 +0000 Subject: [PATCH] Introducing FontList::hasChangeInRange() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21067 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/FontList.cpp | 16 ++++++++++++++++ src/FontList.h | 6 ++++++ src/Paragraph.cpp | 12 +----------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/FontList.cpp b/src/FontList.cpp index a9e9b79011..5906cb4a36 100644 --- a/src/FontList.cpp +++ b/src/FontList.cpp @@ -211,4 +211,20 @@ Font_size FontList::highestInRange return maxsize; } + +bool FontList::hasChangeInRange(pos_type pos, int len) const +{ + // FIXME: can't we use fontIterator(pos) instead? + const_iterator cit = list_.begin(); + const_iterator end = list_.end(); + for (; cit != end; ++cit) { + if (cit->pos() >= pos) + break; + } + if (cit != end && pos + len - 1 > cit->pos()) + return false; + + return true; +} + } // namespace lyx diff --git a/src/FontList.h b/src/FontList.h index 57d6d72950..e99c4a9fa5 100644 --- a/src/FontList.h +++ b/src/FontList.h @@ -103,6 +103,12 @@ public: Font_size def_size ) const; + /// is there a font change in middle of the word? + bool hasChangeInRange( + pos_type pos, ///< position in the paragraph. + int len ///< length of the range to check. + ) const; + private: /// List list_; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index ce0466f017..a324d80989 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -600,17 +600,7 @@ bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const return false; } - // is there a font change in middle of the word? - FontList::const_iterator cit = fontlist_.begin(); - FontList::const_iterator end = fontlist_.end(); - for (; cit != end; ++cit) { - if (cit->pos() >= pos) - break; - } - if (cit != end && pos + len - 1 > cit->pos()) - return false; - - return true; + return fontlist_.hasChangeInRange(pos, len); }