On Mon, Aug 15, 2005 at 05:07:33PM +0300, Martin Vermeer wrote:

...

> > | So, concludingly, I am pretty sure some of this (at least the enum
> > | stuff, and appendix number labels, which my patch doesn't even address
> > | yet) worked right around version 1.2. I could prepare a patch only fixing
> > | those two things if you like... but the .[Ch] stuff of it would look
> > | just the same as in this one.
> > 
> > My main reaons for being so unwilling is the changes to the .layout
> > format. It really looks like a cludge to me. (even the existing one)
> 
> Well I don't like it any more than you. But what would you do instead?
> Hardwire it? It used to be hardwired.

Here is the hardwired alternative. No layout changes. This restores
Hebrew functionality to status around LyX 1.2... and doesn't even look
too bad.

- Martin 

Index: buffer_funcs.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer_funcs.C,v
retrieving revision 1.31
diff -u -p -r1.31 buffer_funcs.C
--- buffer_funcs.C      9 Jun 2005 09:58:05 -0000       1.31
+++ buffer_funcs.C      15 Aug 2005 19:45:01 -0000
@@ -23,6 +23,7 @@
 #include "Floating.h"
 #include "FloatList.h"
 #include "gettext.h"
+#include "language.h"
 #include "LaTeX.h"
 #include "lyxtextclass.h"
 #include "paragraph.h"
@@ -440,7 +441,8 @@ void setCounter(Buffer const & buf, ParI
 
                counters.step(enumcounter);
 
-               par.params().labelString(counters.enumLabel(enumcounter));
+               par.params().labelString(counters.enumLabel(enumcounter,
+                       par.getParLanguage(bufparams)->lang()));
        } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
                counters.step("bibitem");
                int number = counters.value("bibitem");
@@ -522,7 +524,8 @@ string expandLabel(Buffer const & buf,
                }
        }
 
-       return tclass.counters().counterLabel(fmt);
+       // Label format may depend on buffer language (hebrew!)
+       return tclass.counters().counterLabel(fmt, 
buf.params().language->lang());
 }
 
 
Index: counters.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/counters.C,v
retrieving revision 1.34
diff -u -p -r1.34 counters.C
--- counters.C  6 Jan 2005 16:39:22 -0000       1.34
+++ counters.C  15 Aug 2005 19:45:02 -0000
@@ -260,7 +260,8 @@ string const romanCounter(int const n)
 } // namespace anon
 
 
-string Counters::labelItem(string const & ctr, string const & numbertype)
+string Counters::labelItem(string const & ctr, string const & numbertype,
+       string const & language)
 {
        if (counterList.find(ctr) == counterList.end()) {
                lyxerr << "Counter " << ctr << " does not exist." << endl;
@@ -271,10 +272,16 @@ string Counters::labelItem(string const 
                return string(1, hebrewCounter(value(ctr)));
 
        if (numbertype == "alph")
-               return string(1, loweralphaCounter(value(ctr)));
+               if (language == "hebrew")
+                       return string(1, hebrewCounter(value(ctr)));
+               else
+                       return string(1, loweralphaCounter(value(ctr)));
 
        if (numbertype == "Alph")
-               return string(1, alphaCounter(value(ctr)));
+               if (language == "hebrew")
+                       return string(1, hebrewCounter(value(ctr)));
+               else
+                       return string(1, alphaCounter(value(ctr)));
 
        if (numbertype == "roman")
                return lowerromanCounter(value(ctr));
@@ -286,7 +293,7 @@ string Counters::labelItem(string const 
 }
 
 
-string Counters::counterLabel(string const & format)
+string Counters::counterLabel(string const & format, string const & language)
 {
        string label = format;
        while (true) {
@@ -305,7 +312,7 @@ string Counters::counterLabel(string con
                        break;
                string const numbertype(label, i + 1, j - i - 1);
                string const counter(label, j + 1, k - j - 1);
-               string const rep = labelItem(counter, numbertype);
+               string const rep = labelItem(counter, numbertype, language);
                label = string(label, 0, i) + rep + string(label, k + 1, 
string::npos);
                //lyxerr << "  : " << " (" << counter  << ","
                //      << numbertype << ") -> " << label << endl;
@@ -315,11 +322,11 @@ string Counters::counterLabel(string con
 }
 
 
-string Counters::enumLabel(string const & ctr, string const & langtype)
+string Counters::enumLabel(string const & ctr, string const & language)
 {
        ostringstream os;
 
-       if (langtype == "hebrew") {
+       if (language == "hebrew") {
                if (ctr == "enumi")
                        os << '.' << value("enumi");
                else if (ctr == "enumii")
Index: counters.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/counters.h,v
retrieving revision 1.17
diff -u -p -r1.17 counters.h
--- counters.h  6 Oct 2003 15:42:13 -0000       1.17
+++ counters.h  15 Aug 2005 19:45:03 -0000
@@ -76,13 +76,17 @@ public:
        void copy(Counters & from, Counters & to, std::string const & match = 
std::string());
        /// A complete expanded label, like 2.1.4 for a subsubsection
        /// according to the given format
-       std::string counterLabel(std::string const & format);
+       std::string counterLabel(std::string const & format, 
+               std::string const & language);
        /// A complete label, like 1.a for enumerations
-       std::string enumLabel(std::string const & ctr, std::string const & 
langtype = "latin");
+       std::string enumLabel(std::string const & ctr, 
+               std::string const & language);
 private:
        /// A counter label's single item, 1 for subsection number in
        /// the 2.1.4 subsubsection number label.
-       std::string labelItem(std::string const & ctr, std::string const & 
numbertype);
+       std::string labelItem(std::string const & ctr, 
+               std::string const & numbertype,
+               std::string const & language);
        /// Maps counter (layout) names to actual counters.
        typedef std::map<std::string, Counter> CounterList;
        /// Instantiate.

Attachment: pgpYI2LALsjAP.pgp
Description: PGP signature

Reply via email to