diff --git a/src/InsetList.cpp b/src/InsetList.cpp index 057c82d00e..d69211dbd4 100644 --- a/src/InsetList.cpp +++ b/src/InsetList.cpp @@ -52,6 +52,21 @@ InsetList::InsetList(InsetList const & il) } +InsetList::InsetList(InsetList const & il, pos_type beg, pos_type end) +{ + InsetList::const_iterator cit = il.begin(); + InsetList::const_iterator cend = il.end(); + for (; cit != cend; ++cit) { + if (cit->pos < beg) + continue; + if (cit->pos >= end) + break; + // Add a new entry in the insetlist_. + insert(cit->inset->clone(), cit->pos - beg); + } +} + + InsetList::~InsetList() { List::iterator it = list_.begin(); diff --git a/src/InsetList.h b/src/InsetList.h index f394c11a66..392573b54f 100644 --- a/src/InsetList.h +++ b/src/InsetList.h @@ -31,6 +31,9 @@ public: InsetList() {} /// InsetList(InsetList const &); + /// Partial copy constructor. + /// Copy the InsetList contents from \p beg to \p end (without end). + InsetList(InsetList const &, pos_type beg, pos_type end); /// void setBuffer(Buffer &); diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 4016623b4c..991ab14a75 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -251,7 +251,8 @@ Paragraph::Private::Private(Private const & p, Paragraph * owner) Paragraph::Private::Private(Private const & p, Paragraph * owner, pos_type beg, pos_type end) - : owner_(owner), inset_owner_(p.inset_owner_), fontlist_(p.fontlist_), + : owner_(owner), inset_owner_(p.inset_owner_), + insetlist_(p.insetlist_, beg, end), params_(p.params_), changes_(p.changes_), begin_of_body_(p.begin_of_body_), words_(p.words_), layout_(p.layout_) @@ -260,16 +261,7 @@ Paragraph::Private::Private(Private const & p, Paragraph * owner, if (beg >= pos_type(p.text_.size())) return; text_ = p.text_.substr(beg, end - beg); - InsetList::const_iterator icit = p.insetlist_.begin(); - InsetList::const_iterator iend = p.insetlist_.end(); - for (; icit != iend; ++icit) { - if (icit->pos < beg) - continue; - if (icit->pos >= end) - break; - // Add a new entry in the insetlist_. - insetlist_.insert(icit->inset, icit->pos - beg); - } + FontList::const_iterator fcit = fontlist_.begin(); FontList::const_iterator fend = fontlist_.end(); for (; fcit != fend; ++fcit) {