mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
Paragraph: Add a partial copy ctor that will get used in next commit.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26000 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c157c1b809
commit
236460445a
@ -83,6 +83,8 @@ public:
|
|||||||
Private(Paragraph * owner, Layout const & layout);
|
Private(Paragraph * owner, Layout const & layout);
|
||||||
/// "Copy constructor"
|
/// "Copy constructor"
|
||||||
Private(Private const &, Paragraph * owner);
|
Private(Private const &, Paragraph * owner);
|
||||||
|
/// Copy constructor from \p beg to \p end
|
||||||
|
Private(Private const &, Paragraph * owner, pos_type beg, pos_type end);
|
||||||
|
|
||||||
///
|
///
|
||||||
void insertChar(pos_type pos, char_type c, Change const & change);
|
void insertChar(pos_type pos, char_type c, Change const & change);
|
||||||
@ -247,6 +249,43 @@ 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_),
|
||||||
|
params_(p.params_), changes_(p.changes_),
|
||||||
|
begin_of_body_(p.begin_of_body_), words_(p.words_),
|
||||||
|
layout_(p.layout_)
|
||||||
|
{
|
||||||
|
id_ = paragraph_id++;
|
||||||
|
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) {
|
||||||
|
if (fcit->pos() < beg)
|
||||||
|
continue;
|
||||||
|
if (fcit->pos() >= end) {
|
||||||
|
// Add last entry in the fontlist_.
|
||||||
|
fontlist_.set(text_.size() - 1, fcit->font());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Add a new entry in the fontlist_.
|
||||||
|
fontlist_.set(fcit->pos() - beg, fcit->font());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Paragraph::isChanged(pos_type start, pos_type end) const
|
bool Paragraph::isChanged(pos_type start, pos_type end) const
|
||||||
{
|
{
|
||||||
LASSERT(start >= 0 && start <= size(), /**/);
|
LASSERT(start >= 0 && start <= size(), /**/);
|
||||||
@ -1060,6 +1099,14 @@ Paragraph::Paragraph(Paragraph const & par)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Paragraph::Paragraph(Paragraph const & par, pos_type beg, pos_type end)
|
||||||
|
: itemdepth(par.itemdepth),
|
||||||
|
d(new Paragraph::Private(*par.d, this, beg, end))
|
||||||
|
{
|
||||||
|
registerWords();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Paragraph & Paragraph::operator=(Paragraph const & par)
|
Paragraph & Paragraph::operator=(Paragraph const & par)
|
||||||
{
|
{
|
||||||
// needed as we will destroy the private part before copying it
|
// needed as we will destroy the private part before copying it
|
||||||
|
@ -89,6 +89,9 @@ public:
|
|||||||
Paragraph();
|
Paragraph();
|
||||||
///
|
///
|
||||||
Paragraph(Paragraph const &);
|
Paragraph(Paragraph const &);
|
||||||
|
/// Partial copy constructor.
|
||||||
|
/// Copy the Paragraph contents from \p beg to \p end (without end).
|
||||||
|
Paragraph(Paragraph const & par, pos_type beg, pos_type end);
|
||||||
///
|
///
|
||||||
Paragraph & operator=(Paragraph const &);
|
Paragraph & operator=(Paragraph const &);
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user