mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 14:04:25 +00:00
2003-05-01 Lars Gullik Bj�nnes <larsbj@gullik.net>
* CutAndPaste.C (pasteSelection): copy paragraphlist the nice way. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6909 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
107c91ace9
commit
f6493c22aa
@ -1,3 +1,7 @@
|
|||||||
|
2003-05-01 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
|
* CutAndPaste.C (pasteSelection): copy paragraphlist the nice way.
|
||||||
|
|
||||||
2003-05-01 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2003-05-01 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* CutAndPaste.C (pasteSelection): remove some unneeded code.
|
* CutAndPaste.C (pasteSelection): remove some unneeded code.
|
||||||
@ -7,7 +11,6 @@
|
|||||||
* CutAndPaste.C (resetOwnerAndChanges): new helper functor
|
* CutAndPaste.C (resetOwnerAndChanges): new helper functor
|
||||||
(copySelection): clean up a bit.
|
(copySelection): clean up a bit.
|
||||||
(pasteSelection): use make_pair
|
(pasteSelection): use make_pair
|
||||||
(pasteSelection): remove some unneeded code.
|
|
||||||
|
|
||||||
* ParagraphList.C (ParagraphList): implement copy constructor
|
* ParagraphList.C (ParagraphList): implement copy constructor
|
||||||
(operator=): implement, base on copy constructor.
|
(operator=): implement, base on copy constructor.
|
||||||
|
@ -202,24 +202,15 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
|
|
||||||
lyx::Assert (pos <= pit->size());
|
lyx::Assert (pos <= pit->size());
|
||||||
|
|
||||||
// make a copy of the simple cut_buffer
|
// Make a copy of the simple cut_buffer.
|
||||||
#if 1
|
|
||||||
ParagraphList simple_cut_clone;
|
|
||||||
ParagraphList::iterator it = paragraphs.begin();
|
|
||||||
ParagraphList::iterator end = paragraphs.end();
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
simple_cut_clone.push_back(new Paragraph(*it, false));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Later we want it done like this:
|
|
||||||
ParagraphList simple_cut_clone = paragraphs;
|
ParagraphList simple_cut_clone = paragraphs;
|
||||||
#endif
|
|
||||||
// now remove all out of the buffer which is NOT allowed in the
|
// Now remove all out of the buffer which is NOT allowed in the
|
||||||
// new environment and set also another font if that is required
|
// new environment and set also another font if that is required.
|
||||||
ParagraphList::iterator tmpbuf = paragraphs.begin();
|
ParagraphList::iterator tmpbuf = paragraphs.begin();
|
||||||
int depth_delta = pit->params().depth() - tmpbuf->params().depth();
|
int depth_delta = pit->params().depth() - tmpbuf->params().depth();
|
||||||
|
|
||||||
// make sure there is no class difference
|
// Make sure there is no class difference.
|
||||||
#warning current_view used here
|
#warning current_view used here
|
||||||
SwitchLayoutsBetweenClasses(textclass, tc, &*tmpbuf,
|
SwitchLayoutsBetweenClasses(textclass, tc, &*tmpbuf,
|
||||||
current_view->buffer()->params);
|
current_view->buffer()->params);
|
||||||
@ -238,11 +229,13 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
tmpbuf->params().depth(tmpbuf->params().depth() + depth_delta);
|
tmpbuf->params().depth(tmpbuf->params().depth() + depth_delta);
|
||||||
if (tmpbuf->params().depth() > max_depth)
|
if (tmpbuf->params().depth() > max_depth)
|
||||||
tmpbuf->params().depth(max_depth);
|
tmpbuf->params().depth(max_depth);
|
||||||
// only set this from the 2nd on as the 2nd depends for maxDepth
|
|
||||||
// still on pit
|
// Only set this from the 2nd on as the 2nd depends
|
||||||
|
// for maxDepth still on pit.
|
||||||
if (tmpbuf->previous() != pit)
|
if (tmpbuf->previous() != pit)
|
||||||
max_depth = tmpbuf->getMaxDepthAfter();
|
max_depth = tmpbuf->getMaxDepthAfter();
|
||||||
// set the inset owner of this paragraph
|
|
||||||
|
// Set the inset owner of this paragraph.
|
||||||
tmpbuf->setInsetOwner(pit->inInset());
|
tmpbuf->setInsetOwner(pit->inInset());
|
||||||
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
|
for (pos_type i = 0; i < tmpbuf->size(); ++i) {
|
||||||
if (tmpbuf->getChar(i) == Paragraph::META_INSET) {
|
if (tmpbuf->getChar(i) == Paragraph::META_INSET) {
|
||||||
@ -250,11 +243,7 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
tmpbuf->erase(i--);
|
tmpbuf->erase(i--);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if 0
|
|
||||||
LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params, i, outerFont(tmpbuf, pars));
|
|
||||||
#else
|
|
||||||
LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params, i, outerFont(pit, pars));
|
LyXFont f1 = tmpbuf->getFont(current_view->buffer()->params, i, outerFont(pit, pars));
|
||||||
#endif
|
|
||||||
LyXFont f2 = f1;
|
LyXFont f2 = f1;
|
||||||
if (!pit->checkInsertChar(f1)) {
|
if (!pit->checkInsertChar(f1)) {
|
||||||
tmpbuf->erase(i--);
|
tmpbuf->erase(i--);
|
||||||
@ -265,11 +254,11 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make the buf exactly the same layout than
|
// Make the buf exactly the same layout than
|
||||||
// the cursor paragraph
|
// the cursor paragraph.
|
||||||
paragraphs.begin()->makeSameLayout(*pit);
|
paragraphs.begin()->makeSameLayout(*pit);
|
||||||
|
|
||||||
// find the end of the buffer
|
// Find the end of the buffer.
|
||||||
// FIXME: change this to end() - 1
|
// FIXME: change this to end() - 1
|
||||||
ParagraphList::iterator lastbuffer = paragraphs.begin();
|
ParagraphList::iterator lastbuffer = paragraphs.begin();
|
||||||
while (boost::next(lastbuffer) != paragraphs.end())
|
while (boost::next(lastbuffer) != paragraphs.end())
|
||||||
@ -277,17 +266,18 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
|
|
||||||
bool paste_the_end = false;
|
bool paste_the_end = false;
|
||||||
|
|
||||||
// open the paragraph for inserting the buf
|
// Open the paragraph for inserting the buf
|
||||||
// if necessary
|
// if necessary.
|
||||||
if (pit->size() > pos || !pit->next()) {
|
if (pit->size() > pos || !pit->next()) {
|
||||||
breakParagraphConservative(current_view->buffer()->params,
|
breakParagraphConservative(current_view->buffer()->params,
|
||||||
pars, pit, pos);
|
pars, pit, pos);
|
||||||
paste_the_end = true;
|
paste_the_end = true;
|
||||||
}
|
}
|
||||||
// set the end for redoing later
|
|
||||||
|
// Set the end for redoing later.
|
||||||
ParagraphList::iterator endpit = boost::next(boost::next(pit));
|
ParagraphList::iterator endpit = boost::next(boost::next(pit));
|
||||||
|
|
||||||
// paste it!
|
// Paste it!
|
||||||
lastbuffer->next(pit->next());
|
lastbuffer->next(pit->next());
|
||||||
pit->next()->previous(&*lastbuffer);
|
pit->next()->previous(&*lastbuffer);
|
||||||
|
|
||||||
@ -298,10 +288,10 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
lastbuffer = pit;
|
lastbuffer = pit;
|
||||||
|
|
||||||
mergeParagraph(current_view->buffer()->params, pars, pit);
|
mergeParagraph(current_view->buffer()->params, pars, pit);
|
||||||
// store the new cursor position
|
// Store the new cursor position.
|
||||||
pit = lastbuffer;
|
pit = lastbuffer;
|
||||||
pos = lastbuffer->size();
|
pos = lastbuffer->size();
|
||||||
// maybe some pasting
|
// Maybe some pasting.
|
||||||
if (boost::next(lastbuffer) != paragraphs.end() && paste_the_end) {
|
if (boost::next(lastbuffer) != paragraphs.end() && paste_the_end) {
|
||||||
if (boost::next(lastbuffer)->hasSameLayout(*lastbuffer)) {
|
if (boost::next(lastbuffer)->hasSameLayout(*lastbuffer)) {
|
||||||
mergeParagraph(current_view->buffer()->params, pars,
|
mergeParagraph(current_view->buffer()->params, pars,
|
||||||
@ -317,7 +307,7 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
|
|||||||
} else
|
} else
|
||||||
boost::next(lastbuffer)->stripLeadingSpaces();
|
boost::next(lastbuffer)->stripLeadingSpaces();
|
||||||
}
|
}
|
||||||
// restore the simple cut buffer
|
// restore the simple cut buffer.
|
||||||
paragraphs = simple_cut_clone;
|
paragraphs = simple_cut_clone;
|
||||||
|
|
||||||
return make_pair(PitPosPair(pit, pos), endpit);
|
return make_pair(PitPosPair(pit, pos), endpit);
|
||||||
|
Loading…
Reference in New Issue
Block a user