]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfont.C
Dekel language/encoding patch + a few fixes
[lyx.git] / src / lyxfont.C
index 07dca6dcac5021a66f7aa27ffde78b8034c966b4..0c783cb148bad8df1807953eb39bfb8ba778e03a 100644 (file)
@@ -24,6 +24,7 @@
 #include "lyxlex.h"
 #include "FontLoader.h"
 #include "support/lstrings.h"
+#include "bufferparams.h" // stateText
 
 using std::ostream;
 using std::endl;
@@ -289,6 +290,7 @@ void LyXFont::update(LyXFont const & newfont,
        setNoun(setMisc(newfont.noun(), noun()));
        setLatex(setMisc(newfont.latex(), latex()));
 
+       setNumber(setMisc(newfont.number(), number()));
        if (newfont.language() == language() && toggleall)
                if (language() == document_language)
                        setLanguage(default_language);
@@ -380,14 +382,9 @@ bool LyXFont::resolved() const
 
 
 /// Build GUI description of font state
-string LyXFont::stateText() const
+string const LyXFont::stateText(BufferParams * params) const
 {
-#ifdef HAVE_SSTREAM
        std::ostringstream ost;
-#else
-       char str[1024];
-       ostrstream ost(str, 1024);
-#endif
        if (family() != INHERIT_FAMILY)
                ost << _(GUIFamilyNames[family()]) << ", ";
        if (series() != INHERIT_SERIES)
@@ -410,13 +407,12 @@ string LyXFont::stateText() const
                ost << _("Latex ") << _(GUIMiscNames[latex()]) << ", ";
        if (bits == inherit)
                ost << _("Default") << ", ";
-       ost << _("Language: ") << _(language()->display.c_str());
-#ifdef HAVE_SSTREAM
+       if (!params || (language() != params->language))
+               ost << _("Language: ") << _(language()->display().c_str()) << ", ";
+       if (number() != OFF)
+               ost << _("  Number ") << _(GUIMiscNames[number()]);
+
        string buf(ost.str().c_str());
-#else
-       ost << '\0';
-       string buf(ost.str());
-#endif
        buf = strip(buf, ' ');
        buf = strip(buf, ',');
        return buf;
@@ -521,7 +517,7 @@ LyXFont & LyXFont::setGUISize(string const & siz)
 
 
 // Returns size in latex format
-string LyXFont::latexSize() const
+string const LyXFont::latexSize() const
 {
        return LaTeXSizeNames[size()];
 }
@@ -619,6 +615,9 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
        if (orgfont.emph() != emph()) {
                os << "\\emph " << LyXMiscNames[emph()] << " \n";
        }
+       if (orgfont.number() != number()) {
+               os << "\\numeric " << LyXMiscNames[number()] << " \n";
+       }
        if (orgfont.underbar() != underbar()) {
                // This is only for backwards compatibility
                switch (underbar()) {
@@ -657,14 +656,14 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
        if (orgfont.color() != color()) {
                // To make us file compatible with older
                // lyx versions we emit "default" instead
-               // of "ignore"
+               // of "inherit"
                string col_str(lcolor.getLyXName(color()));
                if (col_str == "inherit") col_str = "default";
                os << "\\color " << col_str << "\n";
        }
        if (orgfont.language() != language()) {
                if (language())
-                       os << "\\lang " << language()->lang << "\n";
+                       os << "\\lang " << language()->lang() << "\n";
                else
                        os << "\\lang unknown\n";
        }
@@ -679,27 +678,31 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
        int count = 0;
        bool env = false;
 
-       if (language() != base.language() && language() != prev.language()) {
+       if (language()->babel() != base.language()->babel() &&
+           language()->babel() != prev.language()->babel()) {
                if (isRightToLeft() != prev.isRightToLeft()) {
                        if (isRightToLeft()) {
                                os << "\\R{";
                                count += 3;
-                               env = true; //We have opened a new environment
                        } else {
                                os << "\\L{";
                                count += 3;
-                               env = true; //We have opened a new environment
                        }
                } else {
                        string tmp = '{' + 
                                subst(lyxrc.language_command_begin,
-                                     "$$lang", language()->lang);
+                                     "$$lang", language()->babel());
                        os << tmp;
                        count += tmp.length();
-                       env = true; //We have opened a new environment
                }
        }
 
+       if (number() == ON && prev.number() != ON &&
+           language()->lang() == "hebrew") {
+               os << "{\\beginL ";
+               count += 9;
+       }
+
        LyXFont f = *this;
        f.reduce(base);
        
@@ -724,7 +727,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
                count += strlen(LaTeXShapeNames[f.shape()]) + 2;
                env = true; //We have opened a new environment
        }
-       if (f.color() != LColor::inherit) {
+       if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
                os << "\\textcolor{"
                   << lcolor.getLaTeXName(f.color())
                   << "}{";
@@ -771,18 +774,13 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
        int count = 0;
        bool env = false;
 
-       if (language() != base.language() && language() != next.language()) {
-               os << "}";
-               ++count;
-               env = true; // Size change need not bother about closing env.
-       }
-
        LyXFont f = *this; // why do you need this?
        f.reduce(base); // why isn't this just "reduce(base);" (Lgb)
        // Because this function is const. Everything breaks if this
        // method changes the font it represents. There is no speed penalty
        // by using the temporary. (Asger)
 
+
        if (f.family() != INHERIT_FAMILY) {
                os << '}';
                ++count;
@@ -798,7 +796,7 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
                ++count;
                env = true; // Size change need not bother about closing env.
        }
-       if (f.color() != LColor::inherit) {
+       if (f.color() != LColor::inherit && f.color() != LColor::ignore) {
                os << '}';
                ++count;
                env = true; // Size change need not bother about closing env.
@@ -826,6 +824,17 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
                }
        }
 
+       if (number() == ON && next.number() != ON &&
+           language()->lang() == "hebrew") {
+               os << "\\endL}";
+               count += 6;
+       }
+
+       if (language() != base.language() && language() != next.language()) {
+               os << "}";
+               ++count;
+       }
+
        return count;
 }