X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetquotes.C;h=d4e1541ad8721a8bf7ee7bd98c4189d8c000f664;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=695187a4945b94bf99cf013fd01c2022dea77689;hpb=76a135cf07b775033b3031d609e6e0a084af1c91;p=lyx.git diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 695187a494..d4e1541ad8 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -15,17 +15,19 @@ #endif #include "insetquotes.h" -#include "support/lyxlib.h" -#include "debug.h" -#include "lyxfont.h" -#include "lyxrc.h" -#include "buffer.h" -#include "LaTeXFeatures.h" + +#include "support/LAssert.h" #include "support/lstrings.h" +#include "BufferView.h" +#include "LaTeXFeatures.h" #include "Painter.h" +#include "buffer.h" +#include "debug.h" #include "font.h" #include "language.h" -#include "BufferView.h" +#include "lyxfont.h" +#include "lyxrc.h" +#include "paragraph.h" using std::ostream; using std::endl; @@ -85,7 +87,7 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params) { // Decide whether left or right switch (c) { - case ' ': case '(': case '{': case '[': case '-': case ':': + case ' ': case '(': case Paragraph::META_HFILL: case Paragraph::META_NEWLINE: side_ = LeftQ; // left quote @@ -145,7 +147,7 @@ void InsetQuotes::parseString(string const & s) } -string const InsetQuotes::dispString(Language const * doclang) const +string const InsetQuotes::dispString(Language const * loclang) const { string disp; disp += quote_char[quote_index[side_][language_]]; @@ -153,14 +155,25 @@ string const InsetQuotes::dispString(Language const * doclang) const disp += disp; if (lyxrc.font_norm_type == LyXRC::ISO_8859_1 - || lyxrc.font_norm_type == LyXRC::ISO_8859_15) + || lyxrc.font_norm_type == LyXRC::ISO_8859_3 + || lyxrc.font_norm_type == LyXRC::ISO_8859_4 + || lyxrc.font_norm_type == LyXRC::ISO_8859_9) { + if (disp == "'") + disp = "´"; + else if (disp == "''") + disp = "´´"; + } + if (lyxrc.font_norm_type == LyXRC::ISO_8859_1 + || lyxrc.font_norm_type == LyXRC::ISO_8859_9 + || lyxrc.font_norm_type == LyXRC::ISO_8859_15) { if (disp == "<<") disp = '«'; else if (disp == ">>") disp = '»'; + } // in french, spaces are added inside double quotes - if (times_ == DoubleQ && doclang->code() == "fr") { + if (times_ == DoubleQ && prefixIs(loclang->code(), "fr")) { if (side_ == LeftQ) disp += " "; else @@ -183,9 +196,9 @@ int InsetQuotes::descent(BufferView *, LyXFont const & font) const } -int InsetQuotes::width(BufferView * bv, LyXFont const & font) const +int InsetQuotes::width(BufferView *, LyXFont const & font) const { - string text = dispString(bv->buffer()->getLanguage()); + string const text = dispString(font.language()); int w = 0; for (string::size_type i = 0; i < text.length(); ++i) { @@ -201,21 +214,23 @@ int InsetQuotes::width(BufferView * bv, LyXFont const & font) const } +#if 0 LyXFont const InsetQuotes::convertFont(LyXFont const & f) const { +#if 1 + return f; +#else LyXFont font(f); -#ifndef NO_LATEX - // quotes-insets cannot be latex of any kind - font.setLatex(LyXFont::OFF); -#endif return font; +#endif } +#endif void InsetQuotes::draw(BufferView * bv, LyXFont const & font, int baseline, float & x, bool) const { - string text = dispString(bv->buffer()->getLanguage()); + string const text = dispString(font.language()); bv->painter().text(int(x), baseline, text, font); x += width(bv, font); @@ -235,36 +250,41 @@ void InsetQuotes::write(Buffer const *, ostream & os) const void InsetQuotes::read(Buffer const *, LyXLex & lex) { lex.nextToken(); - parseString(lex.GetString()); + parseString(lex.getString()); lex.next(); - string tmp(lex.GetString()); - if (tmp != "\\end_inset") - lyxerr << "LyX Warning: Missing \\end_inset " - "in InsetQuotes::Read." << endl; + if (lex.getString() != "\\end_inset") { + lex.printError("Missing \\end_inset at this point"); + } } extern bool use_babel; int InsetQuotes::latex(Buffer const * buf, ostream & os, - bool /*fragile*/, bool) const + bool /*fragile*/, bool /* free_spc */) const { - string const doclang = buf->getLanguage()->babel(); - int quoteind = quote_index[side_][language_]; + // How do we get the local language here?? + lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this); + lyx::Assert(curr_pos != -1); + string const curr_lang = + parOwner()->getFont(buf->params, + curr_pos).language()->babel(); + + const int quoteind = quote_index[side_][language_]; string qstr; - if (language_ == FrenchQ && times_ == DoubleQ) { - if (doclang == "frenchb") { - if (side_ == LeftQ) - qstr = "\\og "; //the spaces are important here - else - qstr = " \\fg "; //and here - } else if (doclang == "french") { - if (side_ == LeftQ) - qstr = "<< "; //the spaces are important here - else - qstr = " >>"; //and here - } + if (language_ == FrenchQ && times_ == DoubleQ + && curr_lang == "frenchb") { + if (side_ == LeftQ) + qstr = "\\og "; //the spaces are important here + else + qstr = " \\fg{}"; //and here + } else if (language_ == FrenchQ && times_ == DoubleQ + && curr_lang == "french") { + if (side_ == LeftQ) + qstr = "<< "; //the spaces are important here + else + qstr = " >>"; //and here } else if (lyxrc.fontenc == "T1") { qstr = latex_quote_t1[times_][quoteind]; #ifdef DO_USE_DEFAULT_LANGUAGE @@ -300,7 +320,7 @@ int InsetQuotes::linuxdoc(Buffer const *, ostream & os) const } -int InsetQuotes::docBook(Buffer const *, ostream & os) const +int InsetQuotes::docbook(Buffer const *, ostream & os) const { if (times_ == DoubleQ) { if (side_ == LeftQ) @@ -321,20 +341,24 @@ void InsetQuotes::validate(LaTeXFeatures & features) const { char type = quote_char[quote_index[side_][language_]]; +#ifdef DO_USE_DEFAULT_LANGUAGE if (features.bufferParams().language->lang() == "default" +#else + if (!use_babel +#endif && lyxrc.fontenc != "T1") { if (times_ == SingleQ) switch (type) { - case ',': features.quotesinglbase = true; break; - case '<': features.guilsinglleft = true; break; - case '>': features.guilsinglright = true; break; + case ',': features.require("quotesinglbase"); break; + case '<': features.require("guilsinglleft"); break; + case '>': features.require("guilsinglright"); break; default: break; } else switch (type) { - case ',': features.quotedblbase = true; break; - case '<': features.guillemotleft = true; break; - case '>': features.guillemotright = true; break; + case ',': features.require("quotedblbase"); break; + case '<': features.require("guillemotleft"); break; + case '>': features.require("guillemotright"); break; default: break; } }