>>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:

Juergen> Jean-Marc Lasgouttes wrote:
Jean-Marc> The following patches intend to fix bug 1739. Basically,
Jean-Marc> the problem was that InsetOptArg::latexOptional did not
Jean-Marc> honor correctly the moving_arg parameter of the enclosing
Jean-Marc> paragraph.
>>  I applied it to HEAD and BRANCH_1_3_X.

Juergen> BTW do you have an idea on how to restore the possibility for
Juergen> two optional arguments as discussed here?
Juergen> http://bugzilla.lyx.org/show_bug.cgi?id=724

Could you try the following quick and dirty patch? It should do the
right thing it you set the number of optargs in memoir layouts to more
than one. 

The following problems (still) exists after this patch:

- Insert>Short Title is not disabled after the max number of optargs
  have been inserted

- texrow is not updated correctly using the result of
  InsetOptArg::latexOptional. I am not sure how this is supposed to be
  done. 

JMarc

Index: src/output_latex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/output_latex.C,v
retrieving revision 1.16
diff -u -p -r1.16 output_latex.C
--- src/output_latex.C	15 Nov 2004 13:39:06 -0000	1.16
+++ src/output_latex.C	15 Nov 2004 17:23:26 -0000
@@ -195,18 +195,23 @@ TeXEnvironment(Buffer const & buf,
 }
 
 
-InsetOptArg * optArgInset(Paragraph const & par)
+int latexOptArgInsets(Buffer const & buf, Paragraph const & par, 
+		      ostream & os, OutputParams const & runparams, int number)
 {
+	int lines = 0;
+	
 	// Find the entry.
 	InsetList::const_iterator it = par.insetlist.begin();
 	InsetList::const_iterator end = par.insetlist.end();
-	for (; it != end; ++it) {
-		InsetBase * ins = it->inset;
-		if (ins->lyxCode() == InsetBase::OPTARG_CODE) {
-			return static_cast<InsetOptArg *>(ins);
+	for (; it != end && number > 0 ; ++it) {
+		if (it->inset->lyxCode() == InsetBase::OPTARG_CODE) {
+			InsetOptArg * ins = 
+				static_cast<InsetOptArg *>(it->inset);
+			lines += ins->latexOptional(buf, os, runparams);
+			--number;
 		}
 	}
-	return 0;
+	return lines;
 }
 
 
@@ -308,11 +313,9 @@ TeXOnePar(Buffer const & buf,
 		os << '\\' << style->latexname();
 
 		// Separate handling of optional argument inset.
-		if (style->optionalargs == 1) {
-			InsetOptArg * it = optArgInset(*pit);
-			if (it)
-				it->latexOptional(buf, os, runparams);
-		}
+		if (style->optionalargs > 0)
+			latexOptArgInsets(buf, *pit, os, runparams, 
+					  style->optionalargs);
 		else
 			os << style->latexparam();
 		break;
Index: src/insets/insetoptarg.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetoptarg.C,v
retrieving revision 1.25
diff -u -p -r1.25 insetoptarg.C
--- src/insets/insetoptarg.C	5 Oct 2004 10:11:41 -0000	1.25
+++ src/insets/insetoptarg.C	15 Nov 2004 17:23:26 -0000
@@ -75,10 +75,10 @@ int InsetOptArg::latexOptional(Buffer co
 			       OutputParams const & runparams) const
 {
 	ostringstream ss;
-	InsetText::latex(buf, ss, runparams);
+	int ret = InsetText::latex(buf, ss, runparams);
 	string str = ss.str();
 	if (str.find(']') != string::npos)
 		str = '{' + str + '}';
 	os << '[' << str << ']';
-	return str.length() + 2;
+	return ret;
 }

Reply via email to