mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
* Paragraph::insertInset(): check if inset insertion is allowed before insertion. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26810 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
53d7e1969f
commit
237c713046
@ -449,17 +449,23 @@ void Paragraph::Private::insertChar(pos_type pos, char_type c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::insertInset(pos_type pos, Inset * inset,
|
bool Paragraph::insertInset(pos_type pos, Inset * inset,
|
||||||
Change const & change)
|
Change const & change)
|
||||||
{
|
{
|
||||||
LASSERT(inset, /**/);
|
LASSERT(inset, /**/);
|
||||||
LASSERT(pos >= 0 && pos <= size(), /**/);
|
LASSERT(pos >= 0 && pos <= size(), /**/);
|
||||||
|
|
||||||
|
// Paragraph::insertInset() can be used in cut/copy/paste operation where
|
||||||
|
// d->inset_owner_ is not set yet.
|
||||||
|
if (d->inset_owner_ && d->inset_owner_->insetAllowed(inset->lyxCode()))
|
||||||
|
return false;
|
||||||
|
|
||||||
d->insertChar(pos, META_INSET, change);
|
d->insertChar(pos, META_INSET, change);
|
||||||
LASSERT(d->text_[pos] == META_INSET, /**/);
|
LASSERT(d->text_[pos] == META_INSET, /**/);
|
||||||
|
|
||||||
// Add a new entry in the insetlist_.
|
// Add a new entry in the insetlist_.
|
||||||
d->insetlist_.insert(inset, pos);
|
d->insetlist_.insert(inset, pos);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1303,12 +1309,13 @@ void Paragraph::insertChar(pos_type pos, char_type c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Paragraph::insertInset(pos_type pos, Inset * inset,
|
bool Paragraph::insertInset(pos_type pos, Inset * inset,
|
||||||
Font const & font, Change const & change)
|
Font const & font, Change const & change)
|
||||||
{
|
{
|
||||||
insertInset(pos, inset, change);
|
bool const success = insertInset(pos, inset, change);
|
||||||
// Set the font/language of the inset...
|
// Set the font/language of the inset...
|
||||||
setFont(pos, font);
|
setFont(pos, font);
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,12 +304,15 @@ public:
|
|||||||
///
|
///
|
||||||
void insertChar(pos_type pos, char_type c,
|
void insertChar(pos_type pos, char_type c,
|
||||||
Font const &, Change const & change);
|
Font const &, Change const & change);
|
||||||
///
|
/// Insert \p inset at position \p pos with \p change traking status.
|
||||||
void insertInset(pos_type pos, Inset * inset,
|
/// \return true if successful.
|
||||||
|
bool insertInset(pos_type pos, Inset * inset,
|
||||||
Change const & change);
|
Change const & change);
|
||||||
///
|
/// Insert \p inset at position \p pos with \p change traking status and
|
||||||
void insertInset(pos_type pos, Inset * inset,
|
/// \p font.
|
||||||
Font const &, Change const & change);
|
/// \return true if successful.
|
||||||
|
bool insertInset(pos_type pos, Inset * inset,
|
||||||
|
Font const & font, Change const & change);
|
||||||
///
|
///
|
||||||
Inset * getInset(pos_type pos);
|
Inset * getInset(pos_type pos);
|
||||||
///
|
///
|
||||||
|
@ -46,13 +46,7 @@ static bool moveItem(Paragraph & fromPar, pos_type fromPos,
|
|||||||
// the inset is not in the paragraph any more
|
// the inset is not in the paragraph any more
|
||||||
tmpInset = fromPar.releaseInset(fromPos);
|
tmpInset = fromPar.releaseInset(fromPos);
|
||||||
}
|
}
|
||||||
|
return toPar.insertInset(toPos, tmpInset, tmpFont, tmpChange);
|
||||||
if (!toPar.inInset().insetAllowed(tmpInset->lyxCode())) {
|
|
||||||
delete tmpInset;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
toPar.insertInset(toPos, tmpInset, tmpFont, tmpChange);
|
|
||||||
} else {
|
} else {
|
||||||
fromPar.eraseChar(fromPos, false);
|
fromPar.eraseChar(fromPos, false);
|
||||||
toPar.insertChar(toPos, tmpChar, tmpFont, tmpChange);
|
toPar.insertChar(toPos, tmpChar, tmpFont, tmpChange);
|
||||||
|
Loading…
Reference in New Issue
Block a user