On Tue, Feb 26, 2002 at 06:33:36PM +0100, Jean-Marc Lasgouttes wrote:
 
> >>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:
> 
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> Martin> In the file text2.C around line 550 we find the following
> Martin> code: while (cur.par() != send_cur.par()) { (17 lines)
> Martin> cur.par(cur.par()->next()); } (functionally the same 17 lines,
> Martin> AFAICS)
> 
> Martin> Do I miss something or could this be done simply by
> 
> Martin> do { (17 lines) cur.par(cur.par()->next()); } while (cur.par()
> Martin> != send_cur.par());
> 
> Jean-Marc> I think you are right. And having two identical copies of
> Jean-Marc> code is never good...
> 
> Could you do (and test) a patch?
> 
> JMarc

Ok, here is the patch. How extensive should a test like this be? 
It loads a file, I can change layouts of paragraphs, either individually
(under cursor) or collectively (selection) just fine. As that is what
setLayout is doing, that should be tested -- but what else?

Attached.

Martin

PS. the 'if' statement at the end of the loop is essential ;-)

Index: text2.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text2.C,v
retrieving revision 1.200
diff -u -b -B -p -r1.200 text2.C
--- text2.C     2002/02/20 14:55:16     1.200
+++ text2.C     2002/02/26 16:48:37
@@ -547,7 +547,7 @@ Paragraph * LyXText::setLayout(BufferVie
        LyXLayout const & lyxlayout =
                textclasslist.Style(bview->buffer()->params.textclass, layout);
        
-       while (cur.par() != send_cur.par()) {
+       do {
                cur.par()->setLayout(layout);
                makeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
                Paragraph * fppar = cur.par();
@@ -564,22 +564,10 @@ Paragraph * LyXText::setLayout(BufferVie
                        delete fppar->bibkey;
                        fppar->bibkey = 0;
                }
+               if (cur.par() != send_cur.par())
                cur.par(cur.par()->next());
-       }
-       cur.par()->setLayout(layout);
-       makeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
-       Paragraph * fppar = cur.par();
-       fppar->params().spaceTop(lyxlayout.fill_top ?
-                                VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
-       fppar->params().spaceBottom(lyxlayout.fill_bottom ? 
-                                   VSpace(VSpace::VFILL) : VSpace(VSpace::NONE));
-       if (lyxlayout.margintype == MARGIN_MANUAL)
-               cur.par()->setLabelWidthString(lyxlayout.labelstring());
-       if (lyxlayout.labeltype != LABEL_BIBLIO
-           && fppar->bibkey) {
-               delete fppar->bibkey;
-               fppar->bibkey = 0;
-       }
+       } while (cur.par() != send_cur.par());
+
        return endpar;
 }
 

Attachment: msg33476/pgp00000.pgp
Description: PGP signature

Reply via email to