>>>>> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes:

Jean-Marc> I have a better solution, which is to move enumLabel out of
Jean-Marc> Counters, where it does not belong anyway. The code should
Jean-Marc> go in buffer_funcs.C.

Jean-Marc> I'll post a patch.

Here is an untested patch that I won't have time to test until monday.

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2274
diff -u -p -r1.2274 ChangeLog
--- src/ChangeLog	9 Sep 2005 11:04:51 -0000	1.2274
+++ src/ChangeLog	9 Sep 2005 12:59:16 -0000
@@ -1,3 +1,10 @@
+2005-09-09  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* buffer_funcs.C (setCounter): put the code to compute enum label
+	here (where it belongs).
+
+	* counters.C (enumLabel): move code to buffer_funcs.C.
+
 2005-09-07  Georg Baum  <[EMAIL PROTECTED]>
 
 	* outputparams.[Ch]: store local_font instead of local_language
Index: src/buffer_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.C,v
retrieving revision 1.33
diff -u -p -r1.33 buffer_funcs.C
--- src/buffer_funcs.C	8 Sep 2005 16:57:13 -0000	1.33
+++ src/buffer_funcs.C	9 Sep 2005 12:59:16 -0000
@@ -438,7 +438,27 @@ void setCounter(Buffer const & buf, ParI
 
 		counters.step(enumcounter);
 
-		par.params().labelString(counters.enumLabel(enumcounter, buf));
+		string format;
+
+		switch (par.itemdepth) {
+		case 0:
+			format = N_("\\arabic{enumi}.");
+			break;
+		case 1:
+			format = N_("(\\alph{enumii})");
+			break;
+		case 2:
+			format = N_("\\roman{enumiii}.");
+			break;
+		case 3:
+			format = N_("\\Alph{enumiv}.");
+			break;
+		default:
+			// not a valid enumdepth...
+			break;
+		}
+
+		par.params().labelString(counters.counterLabel(buf.B_(format)));
 	} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
 		counters.step("bibitem");
 		int number = counters.value("bibitem");
Index: src/counters.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/counters.C,v
retrieving revision 1.35
diff -u -p -r1.35 counters.C
--- src/counters.C	8 Sep 2005 16:57:13 -0000	1.35
+++ src/counters.C	9 Sep 2005 12:59:16 -0000
@@ -14,7 +14,6 @@
 
 #include "counters.h"
 #include "debug.h"
-#include "gettext.h"
 
 #include "support/lstrings.h"
 #include "support/convert.h"
@@ -313,25 +312,4 @@ string Counters::counterLabel(string con
 	}
 	//lyxerr << "counterLabel: " << format  << " -> "	<< label << endl;
 	return label;
-}
-
-
-string Counters::enumLabel(string const & ctr, Buffer const & buf)
-{
-	string format;
-
-	if (ctr == "enumi") {
-		format = N_("\\arabic{enumi}.");
-	}
- 	else if (ctr == "enumii") {
-		format = N_("(\\alph{enumii})");
-	}
- 	else if (ctr == "enumiii") { 
-		format = N_("\\roman{enumiii}.");
-	}
- 	else if (ctr == "enumiv") {
-		format = N_("\\Alph{enumiv}.");
-	}
-		
-	return counterLabel(buf.B_(format));
 }
Index: src/counters.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/counters.h,v
retrieving revision 1.18
diff -u -p -r1.18 counters.h
--- src/counters.h	8 Sep 2005 16:57:13 -0000	1.18
+++ src/counters.h	9 Sep 2005 12:59:16 -0000
@@ -18,8 +18,6 @@
 #include <map>
 #include <string>
 
-#include "buffer.h"
-
 /// This represents a single counter.
 class Counter {
 public:
@@ -78,8 +76,6 @@ public:
 	/// A complete expanded label, like 2.1.4 for a subsubsection
 	/// according to the given format
 	std::string counterLabel(std::string const & format);
-	/// A complete label, like 1.a for enumerations
-	std::string enumLabel(std::string const & ctr, Buffer const & buf);
 private:
 	/// A counter label's single item, 1 for subsection number in
 	/// the 2.1.4 subsubsection number label.

Reply via email to