]> git.lyx.org Git - lyx.git/commitdiff
Change the layout also for the last selected paragraph and also if one of
authorJürgen Vigna <jug@sad.it>
Thu, 18 Apr 2002 14:14:06 +0000 (14:14 +0000)
committerJürgen Vigna <jug@sad.it>
Thu, 18 Apr 2002 14:14:06 +0000 (14:14 +0000)
the selected paragraphs does have a different layout.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4025 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/text2.C

index c1c04f4c1ecd5cf9865d8f644f5bb8eaf1daeff7..e0e0556d80472192ff04e7f1cf023c09291f71b6 100644 (file)
@@ -1789,8 +1789,21 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        break;
                }
 
-               if (current_layout != layout) {
-                       LyXText * lt = bv_->getLyXText();
+               bool change_layout = (current_layout != layout);
+               LyXText * lt = bv_->getLyXText();
+               if (!change_layout && lt->selection.set() &&
+                       lt->selection.start.par() != lt->selection.end.par())
+               {
+                       Paragraph * spar = lt->selection.start.par();
+                       Paragraph * epar = lt->selection.end.par()->next();
+                       while(spar != epar) {
+                               if (spar->layout() != current_layout) {
+                                       change_layout = true;
+                                       break;
+                               }
+                       }
+               }
+               if (change_layout) {
                        hideCursor();
                        current_layout = layout;
                        update(lt,
index 72a63796f6b6a5fddc238c79ed3e3fbc57d86f8f..c3af7757ed802aa0cd49b8fb4f59cd872d517c82 100644 (file)
@@ -1,5 +1,12 @@
 2002-04-18  Juergen Vigna  <jug@sad.it>
 
+       * BufferView_pimpl.C (Dispatch): fixed to change layout also if one
+       of the selected paragraph does not have the selected layout also if
+       the last one had!
+
+       * text2.C (setLayout): fixed bug which did not change last selected
+       paragraph.
+
        * tabular.C (OldFormatRead): check also for \\end_inset as Lars
        changed the read and substituted \\end_float with \\end_inset!
 
index 2e5d93d03dbce1152ce206eb782c60541abbfecb..bec3b8529fa38f46f456b4e3c8c6fb4c4a6fa862 100644 (file)
@@ -500,14 +500,16 @@ Paragraph * LyXText::setLayout(BufferView * bview,
        // ok we have a selection. This is always between sstart_cur
        // and sel_end cursor
        cur = sstart_cur;
+       Paragraph * par = sstart_cur.par();
+       Paragraph * epar = send_cur.par()->next();
 
        LyXLayout const & lyxlayout =
                textclasslist[bview->buffer()->params.textclass][layout];
 
        do {
-               cur.par()->applyLayout(layout);
-               makeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
-               Paragraph * fppar = cur.par();
+               par->applyLayout(layout);
+               makeFontEntriesLayoutSpecific(bview->buffer(), par);
+               Paragraph * fppar = par;
                fppar->params().spaceTop(lyxlayout.fill_top ?
                                         VSpace(VSpace::VFILL)
                                         : VSpace(VSpace::NONE));
@@ -515,15 +517,15 @@ Paragraph * LyXText::setLayout(BufferView * bview,
                                            VSpace(VSpace::VFILL)
                                            : VSpace(VSpace::NONE));
                if (lyxlayout.margintype == MARGIN_MANUAL)
-                       cur.par()->setLabelWidthString(lyxlayout.labelstring());
+                       par->setLabelWidthString(lyxlayout.labelstring());
                if (lyxlayout.labeltype != LABEL_BIBLIO
                    && fppar->bibkey) {
                        delete fppar->bibkey;
                        fppar->bibkey = 0;
                }
-               if (cur.par() != send_cur.par())
-                       cur.par(cur.par()->next());
-       } while (cur.par() != send_cur.par());
+               cur.par(par);
+               par = par->next();
+       } while (par != epar);
 
        return endpar;
 }