]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
more guii moving around.
[lyx.git] / src / CutAndPaste.C
index d5306afd315e153d959a6ce4765c403075a11cff..b7727b40406afd6785089fe6c7d001adc0b084f5 100644 (file)
@@ -283,13 +283,13 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                // temporary set *par as previous of tmpbuf as we might have to realize
                // the font.
                tmpbuf->previous(*par);
+
                // make sure there is no class difference
                SwitchLayoutsBetweenClasses(textclass, tc, tmpbuf,
-                                           current_view->buffer()->params);
-               
+                                           current_view->buffer()->params);
+
                Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter(current_view->buffer());
+
                while(tmpbuf) {
                        // if we have a negative jump so that the depth would go below
                        // 0 depth then we have to redo the delta to this new max depth
@@ -408,24 +408,18 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
        if (!par || c1 == c2)
                return ret;
 
+       LyXTextClass const & tclass1 = textclasslist[c1];
+       LyXTextClass const & tclass2 = textclasslist[c2];
        ParIterator end = ParIterator();
        for (ParIterator it = ParIterator(par); it != end; ++it) {
                par = *it;
                string const name = par->layout();
-               LyXTextClass const & tclass = textclasslist[c2];
+               bool hasLayout = tclass2.hasLayout(name);
 
-               bool hasLayout = tclass.hasLayout(name);
-
-               string lay = tclass.defaultLayoutName();
-               if (hasLayout) {
-                       lay = name;
-               } else {
-                       // not found: use default layout
-                       lay = tclass.defaultLayoutName();
-               }
-               par->layout(lay);
+               if (!hasLayout)
+                       par->layout(tclass2.defaultLayoutName());
 
-               if (name != par->layout()) {
+               if (!hasLayout && name != tclass1.defaultLayoutName()) {
                        ++ret;
                        string const s = _("Layout had to be changed from\n")
                                + name + _(" to ")