mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix bug 2476:
* src/CutAndPaste.C (resetOwnerAndChanges): rename to resetParagraph and reset the language of ERT paragraphs, too (copySelectionHelper): adapt to changes above (cutSelection): ditto (copySelection): ditto git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13699 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f6848c168b
commit
c9b081f6f9
@ -24,6 +24,7 @@
|
|||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "insetiterator.h"
|
#include "insetiterator.h"
|
||||||
|
#include "language.h"
|
||||||
#include "lfuns.h"
|
#include "lfuns.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "lyxtext.h"
|
#include "lyxtext.h"
|
||||||
@ -73,12 +74,22 @@ CutStack theCuts(10);
|
|||||||
// when we (hopefully) have a one-for-all paste mechanism.
|
// when we (hopefully) have a one-for-all paste mechanism.
|
||||||
bool dirty_tabular_stack_;
|
bool dirty_tabular_stack_;
|
||||||
|
|
||||||
class resetOwnerAndChanges : public std::unary_function<Paragraph, void> {
|
class resetParagraph : public std::unary_function<Paragraph, Buffer const &> {
|
||||||
public:
|
public:
|
||||||
|
resetParagraph(Buffer const & b) : buffer_(b) {}
|
||||||
void operator()(Paragraph & p) const {
|
void operator()(Paragraph & p) const {
|
||||||
p.cleanChanges();
|
p.cleanChanges();
|
||||||
|
// ERT paragraphs have the Language latex_language.
|
||||||
|
// This is invalid outside of ERT, so we need to change it
|
||||||
|
// to the buffer language.
|
||||||
|
if (p.ownerCode() == InsetBase::ERT_CODE) {
|
||||||
|
p.changeLanguage(buffer_.params(), latex_language,
|
||||||
|
buffer_.getLanguage());
|
||||||
|
}
|
||||||
p.setInsetOwner(0);
|
p.setInsetOwner(0);
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
Buffer const & buffer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -313,7 +324,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void copySelectionHelper(ParagraphList & pars,
|
void copySelectionHelper(Buffer const & buf, ParagraphList & pars,
|
||||||
pit_type startpit, pit_type endpit,
|
pit_type startpit, pit_type endpit,
|
||||||
int start, int end, textclass_type tc)
|
int start, int end, textclass_type tc)
|
||||||
{
|
{
|
||||||
@ -325,7 +336,7 @@ void copySelectionHelper(ParagraphList & pars,
|
|||||||
ParagraphList paragraphs(boost::next(pars.begin(), startpit),
|
ParagraphList paragraphs(boost::next(pars.begin(), startpit),
|
||||||
boost::next(pars.begin(), endpit + 1));
|
boost::next(pars.begin(), endpit + 1));
|
||||||
|
|
||||||
for_each(paragraphs.begin(), paragraphs.end(), resetOwnerAndChanges());
|
for_each(paragraphs.begin(), paragraphs.end(), resetParagraph(buf));
|
||||||
|
|
||||||
// Cut out the end of the last paragraph.
|
// Cut out the end of the last paragraph.
|
||||||
Paragraph & back = paragraphs.back();
|
Paragraph & back = paragraphs.back();
|
||||||
@ -491,7 +502,8 @@ void cutSelection(LCursor & cur, bool doclear, bool realcut)
|
|||||||
|
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer().params();
|
||||||
if (realcut) {
|
if (realcut) {
|
||||||
copySelectionHelper(text->paragraphs(),
|
copySelectionHelper(cur.buffer(),
|
||||||
|
text->paragraphs(),
|
||||||
begpit, endpit,
|
begpit, endpit,
|
||||||
cur.selBegin().pos(), endpos,
|
cur.selBegin().pos(), endpos,
|
||||||
bp.textclass);
|
bp.textclass);
|
||||||
@ -563,7 +575,7 @@ void copySelection(LCursor & cur)
|
|||||||
&& (par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
|
&& (par != cur.selEnd().pit() || pos < cur.selEnd().pos()))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
copySelectionHelper(pars, par, cur.selEnd().pit(),
|
copySelectionHelper(cur.buffer(), pars, par, cur.selEnd().pit(),
|
||||||
pos, cur.selEnd().pos(), cur.buffer().params().textclass);
|
pos, cur.selEnd().pos(), cur.buffer().params().textclass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,7 +585,7 @@ void copySelection(LCursor & cur)
|
|||||||
pars.push_back(Paragraph());
|
pars.push_back(Paragraph());
|
||||||
BufferParams const & bp = cur.buffer().params();
|
BufferParams const & bp = cur.buffer().params();
|
||||||
pars.back().layout(bp.getLyXTextClass().defaultLayout());
|
pars.back().layout(bp.getLyXTextClass().defaultLayout());
|
||||||
for_each(pars.begin(), pars.end(), resetOwnerAndChanges());
|
for_each(pars.begin(), pars.end(), resetParagraph(cur.buffer()));
|
||||||
pars.back().insert(0, grabSelection(cur), LyXFont());
|
pars.back().insert(0, grabSelection(cur), LyXFont());
|
||||||
theCuts.push(make_pair(pars, bp.textclass));
|
theCuts.push(make_pair(pars, bp.textclass));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user