The following patches intend to fix bug 1739. Basically, the problem
was that InsetOptArg::latexOptional did not honor correctly the
moving_arg parameter of the enclosing paragraph.

Comments?

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1021.2.45
diff -u -p -r1.1021.2.45 ChangeLog
--- src/ChangeLog	9 Nov 2004 16:59:02 -0000	1.1021.2.45
+++ src/ChangeLog	10 Nov 2004 13:39:21 -0000
@@ -1,5 +1,9 @@
 2004-11-09  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
+	* paragraph.C (TeXOnePar): use LyXStyle::needprotect and pass it
+	to InsetOptArg::latexOptional as needed (bug 1739)
+	(simpleTeXOnePar): no need to honor needprotect here
+
 	* lengthcommon.C (unitFromString): fix off-by-one error (bug 1682)
 
 2004-11-04  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
Index: src/paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.235.2.3
diff -u -p -r1.235.2.3 paragraph.C
--- src/paragraph.C	27 Sep 2004 10:55:57 -0000	1.235.2.3
+++ src/paragraph.C	10 Nov 2004 13:39:21 -0000
@@ -975,6 +975,8 @@ Paragraph * Paragraph::TeXOnePar(Buffer 
 	else 
 		style = bparams.getLyXTextClass().defaultLayout();
 
+	moving_arg |= style->needprotect;
+
 	Language const * language = getParLanguage(bparams);
 	Language const * doc_language = bparams.language;
 	Language const * previous_language = previous()
@@ -1066,7 +1068,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer 
 		if (style->optionalargs == 1) {
 			InsetOptArg * it = optArgInset(*this);
 			if (it != 0)
-				it->latexOptional(buf, os, false, false);
+				it->latexOptional(buf, os, moving_arg, false);
 		}
 		else
 			os << style->latexparam();
@@ -1353,8 +1355,6 @@ bool Paragraph::simpleTeXOnePar(Buffer c
 	} else {
 		basefont = getLayoutFont(bparams);
 	}
-
-	moving_arg |= style->needprotect;
 
 	// Which font is currently active?
 	LyXFont running_font(basefont);
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.552.2.14
diff -u -p -r1.552.2.14 ChangeLog
--- src/insets/ChangeLog	25 Oct 2004 08:51:39 -0000	1.552.2.14
+++ src/insets/ChangeLog	10 Nov 2004 13:39:21 -0000
@@ -1,3 +1,7 @@
+2004-11-09  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* insetoptarg.C (latexOptional): honor 'fragile' argument (bug 1739)
+
 2004-10-25  Jürgen Spitzmüller  <[EMAIL PROTECTED]>
 
 	* insetfoot.C (latex): use \thanks instead of \footnote on titlepage 
Index: src/insets/insetoptarg.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetoptarg.C,v
retrieving revision 1.4
diff -u -p -r1.4 insetoptarg.C
--- src/insets/insetoptarg.C	1 Dec 2002 22:59:24 -0000	1.4
+++ src/insets/insetoptarg.C	10 Nov 2004 13:39:21 -0000
@@ -76,10 +76,10 @@ int InsetOptArg::latex(Buffer const *, o
 
 
 int InsetOptArg::latexOptional(Buffer const * buf, ostream & os,
-				bool, bool fp) const
+				bool fragile, bool fp) const
 {
 	os << '[';
-	int const i = inset.latex(buf, os, false, fp);
+	int const i = inset.latex(buf, os, fragile, fp);
 	os << ']';
 	return i + 2;
 }
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2031
diff -u -p -r1.2031 ChangeLog
--- src/ChangeLog	9 Nov 2004 19:08:32 -0000	1.2031
+++ src/ChangeLog	10 Nov 2004 14:04:12 -0000
@@ -1,3 +1,11 @@
+2004-11-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* output_latex.C (TeXOnePar): override runparams.moving_arg
+	according to the needprotect value of the current paragraph (bug 1739)
+
+	* paragraph.C (simpleTeXOnePar): no need to override
+	runparams.moving_args here
+
 2004-11-09  Georg Baum  <[EMAIL PROTECTED]>
 
 	* format.[Ch] (getFormatFromFile): new method
Index: src/output_latex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/output_latex.C,v
retrieving revision 1.15
diff -u -p -r1.15 output_latex.C
--- src/output_latex.C	5 Oct 2004 10:11:28 -0000	1.15
+++ src/output_latex.C	10 Nov 2004 14:04:12 -0000
@@ -18,6 +18,7 @@
 #include "encoding.h"
 #include "language.h"
 #include "lyxrc.h"
+#include "outputparams.h"
 #include "paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
@@ -214,7 +215,7 @@ TeXOnePar(Buffer const & buf,
 	  ParagraphList const & paragraphs,
 	  ParagraphList::const_iterator pit,
 	  ostream & os, TexRow & texrow,
-	  OutputParams const & runparams,
+	  OutputParams const & runparams_in,
 	  string const & everypar)
 {
 	lyxerr[Debug::LATEX] << "TeXOnePar...     " << &*pit << " '"
@@ -229,6 +230,9 @@ TeXOnePar(Buffer const & buf,
 		style = pit->layout();
 	else
 		style = bparams.getLyXTextClass().defaultLayout();
+
+	OutputParams runparams = runparams_in;
+	runparams.moving_arg |= style->needprotect;
 
 	Language const * language = pit->getParLanguage(bparams);
 	Language const * doc_language = bparams.language;
Index: src/paragraph.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/paragraph.C,v
retrieving revision 1.389
diff -u -p -r1.389 paragraph.C
--- src/paragraph.C	2 Nov 2004 11:25:16 -0000	1.389
+++ src/paragraph.C	10 Nov 2004 14:04:12 -0000
@@ -929,8 +929,6 @@ bool Paragraph::simpleTeXOnePar(Buffer c
 		basefont = getLayoutFont(bparams, outerfont);
 	}
 
-	bool const moving_arg = runparams.moving_arg | style->needprotect;
-
 	// Which font is currently active?
 	LyXFont running_font(basefont);
 	// Do we have an open font change?
@@ -947,7 +945,8 @@ bool Paragraph::simpleTeXOnePar(Buffer c
 			++column;
 		}
 		if (!asdefault)
-			column += startTeXParParams(bparams, os, moving_arg);
+			column += startTeXParParams(bparams, os, 
+						    runparams.moving_arg);
 	}
 
 	for (pos_type i = 0; i < size(); ++i) {
@@ -971,7 +970,7 @@ bool Paragraph::simpleTeXOnePar(Buffer c
 
 			if (!asdefault)
 				column += startTeXParParams(bparams, os,
-							    moving_arg);
+							    runparams.moving_arg);
 		}
 
 		value_type c = getChar(i);
@@ -1029,7 +1028,6 @@ bool Paragraph::simpleTeXOnePar(Buffer c
 		running_change = change;
 
 		OutputParams rp = runparams;
-		rp.moving_arg = moving_arg;
 		rp.free_spacing = style->free_spacing;
 		rp.local_language = font.language()->babel();
 		rp.intitle = style->intitle;
@@ -1073,7 +1071,7 @@ bool Paragraph::simpleTeXOnePar(Buffer c
 	}
 
 	if (!asdefault) {
-		column += endTeXParParams(bparams, os, moving_arg);
+		column += endTeXParParams(bparams, os, runparams.moving_arg);
 	}
 
 	lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl;

Reply via email to