X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfont.C;h=0c783cb148bad8df1807953eb39bfb8ba778e03a;hb=bd659b25fb6e2df5d02273ee1ce4699aa5723e2e;hp=82d4062bb8b675709e6992b7caed160c0366148c;hpb=e059c633b01937f450ff9fa873cfc6b773aa74cc;p=lyx.git diff --git a/src/lyxfont.C b/src/lyxfont.C index 82d4062bb8..0c783cb148 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -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()) { @@ -655,11 +654,16 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const } } if (orgfont.color() != color()) { - os << "\\color " << lcolor.getLyXName(color()) << "\n"; + // To make us file compatible with older + // lyx versions we emit "default" instead + // 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"; } @@ -674,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); @@ -719,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()) << "}{"; @@ -766,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; @@ -793,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. @@ -821,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; }