X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetQuotes.cpp;h=f5823605543455e820e7fec88a828ced16348efa;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=5fe2939a7df6ed3e6f995c1bab6fa12b973abf25;hpb=c0a59871813d853ba455ec8d39be61db4f4b2848;p=lyx.git diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index 5fe2939a7d..f582360554 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -67,10 +67,11 @@ namespace { * r <> (,,inner quotation``) * j [U+300C]cjk[U+300D] ([U+300E]inner quotation[U+300F]) [CORNER BRACKETS] * k [U+300A]cjkangle[U+300B] ([U+3008]inner quotation[U+3009]) [ANGLE BRACKETS] + * h ,,hungarian'' (>>inner quotation<<) * x dynamic style (inherits document settings) */ -char const * const style_char = "esgpcaqbwfirjkx"; +char const * const style_char = "esgpcaqbwfirjkhx"; char const * const side_char = "lr" ; char const * const level_char = "sd"; @@ -305,6 +306,13 @@ char_type InsetQuotesParams::getQuoteChar(QuoteStyle const & style, QuoteLevel c right_secondary = 0x3009; // RIGHT ANGLE BRACKET break; } + case QuoteStyle::Hungarian: { + left_primary = 0x201e; // ,, + right_primary = 0x201d; // '' + left_secondary = 0x00bb; // >> + right_secondary = 0x00ab; // << + break; + } case QuoteStyle::Dynamic: default: // should not happen @@ -462,79 +470,6 @@ docstring InsetQuotesParams::getLaTeXQuote(char_type c, string const & op, } -docstring InsetQuotesParams::getHTMLQuote(char_type c) const -{ - string res; - - switch (c){ - case 0x201a: // , - res = "‚"; - break; - case 0x2019: // ' - res = "’"; - break; - case 0x2018: // ` - res = "‘"; - break; - case 0x2039: // < - res = "‹"; - break; - case 0x203a: // > - res = "›"; - break; - case 0x0027: // ' (plain) - res = "'"; - break; - case 0x201e: // ,, - res = "„"; - break; - case 0x201d: // '' - res = "”"; - break; - case 0x201c: // `` - res = "“"; - break; - case 0x00ab: // << - res = "«"; - break; - case 0x00bb: // >> - res = "»"; - break; - case 0x0022: // " - res = """; - break; - case 0x300c: // LEFT CORNER BRACKET - res = "「"; - break; - case 0x300d: // RIGHT CORNER BRACKET - res = "」"; - break; - case 0x300e: // LEFT WHITE CORNER BRACKET - res = "『"; - break; - case 0x300f: // RIGHT WHITE CORNER BRACKET - res = "』"; - break; - case 0x300a: // LEFT DOUBLE ANGLE BRACKET - res = "《"; - break; - case 0x300b: // RIGHT DOUBLE ANGLE BRACKET - res = "》"; - break; - case 0x3008: // LEFT ANGLE BRACKET - res = "〈"; - break; - case 0x3009: // RIGHT ANGLE BRACKET - res = "〉"; - break; - default: - break; - } - - return from_ascii(res); -} - - docstring InsetQuotesParams::getXMLQuote(char_type c) const { // Directly output the character Unicode form. @@ -631,11 +566,8 @@ InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteLevel level, bool dynamic = false; if (buf) { global_style_ = buf->masterBuffer()->params().quotes_style; - fontenc_ = buf->masterBuffer()->params().main_font_encoding(); dynamic = buf->masterBuffer()->params().dynamic_quotes; fontspec_ = buf->masterBuffer()->params().useNonTeXFonts; - } else { - fontenc_ = "OT1"; } if (style.empty()) style_ = dynamic ? QuoteStyle::Dynamic : global_style_; @@ -707,6 +639,8 @@ QuoteStyle InsetQuotes::getStyle(string const & s) qs = QuoteStyle::CJK; else if (s == "cjkangle") qs = QuoteStyle::CJKAngle; + else if (s == "hungarian") + qs = QuoteStyle::Hungarian; else if (s == "dynamic") qs = QuoteStyle::Dynamic; @@ -844,7 +778,7 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const docstring qstr; // In pass-thru context, we output plain quotes - if (runparams.pass_thru) + if (runparams.pass_thru || runparams.find_effective()) qstr = (level_ == QuoteLevel::Primary) ? from_ascii("\"") : from_ascii("'"); else if (style == QuoteStyle::Plain && fontspec_) { // For XeTeX and LuaTeX,we need to disable mapping to get straight @@ -881,7 +815,7 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const // Use internal commands in headings with hyperref // (ligatures not featured in PDF strings) qstr = quoteparams.getLaTeXQuote(quotechar, "int", rtl_); - } else if (fontenc_ == "T1" + } else if (runparams.main_fontenc == "T1" && !runparams.local_font->language()->internalFontEncoding()) { // Quotation marks for T1 font encoding // (using ligatures) @@ -895,7 +829,7 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const #else } else if ((!runparams.use_babel #endif - || (fontenc_ != "T1" && fontenc_ != "OT1")) + || (runparams.main_fontenc != "T1" && runparams.main_fontenc != "OT1")) || runparams.isFullUnicode()) { // Standard quotation mark macros // These are also used by babel @@ -935,19 +869,27 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const int InsetQuotes::plaintext(odocstringstream & os, - OutputParams const &, size_t) const + OutputParams const & op, size_t) const { - docstring const str = displayString(); - os << str; - return str.size(); + if (!op.find_effective()) { + docstring const str = displayString(); + os << str; + return str.size(); + } + else { + if (level_ == QuoteLevel::Primary) + os << from_ascii("\""); + else + os << from_ascii("'"); + return 1; + } } -docstring InsetQuotes::getQuoteEntity(bool isHTML) const { +docstring InsetQuotes::getQuoteXMLEntity() const { QuoteStyle style = (style_ == QuoteStyle::Dynamic) ? global_style_ : style_; - docstring res = isHTML ? quoteparams.getHTMLQuote(quoteparams.getQuoteChar(style, level_, side_)) : - quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_)); + docstring res = quoteparams.getXMLQuote(quoteparams.getQuoteChar(style, level_, side_)); // in French, thin spaces are added inside double guillemets if (prefixIs(context_lang_, "fr") @@ -968,13 +910,13 @@ docstring InsetQuotes::getQuoteEntity(bool isHTML) const { void InsetQuotes::docbook(XMLStream & xs, OutputParams const &) const { - xs << XMLStream::ESCAPE_NONE << getQuoteEntity(false); + xs << XMLStream::ESCAPE_NONE << getQuoteXMLEntity(); } docstring InsetQuotes::xhtml(XMLStream & xs, OutputParams const &) const { - xs << XMLStream::ESCAPE_NONE << getQuoteEntity(true); + xs << XMLStream::ESCAPE_NONE << getQuoteXMLEntity(); return docstring(); } @@ -998,7 +940,6 @@ void InsetQuotes::updateBuffer(ParIterator const & it, UpdateType /* utype*/, bo pass_thru_ = it.paragraph().isPassThru(); context_lang_ = font.language()->code(); internal_fontenc_ = font.language()->internalFontEncoding(); - fontenc_ = bp.main_font_encoding(); global_style_ = bp.quotes_style; fontspec_ = bp.useNonTeXFonts; rtl_ = font.isRightToLeft(); @@ -1018,7 +959,8 @@ void InsetQuotes::validate(LaTeXFeatures & features) const #else if (!features.useBabel() #endif - && !features.runparams().isFullUnicode() && fontenc_ != "T1") { + && !features.runparams().isFullUnicode() + && features.runparams().main_fontenc != "T1") { switch (type) { case 0x201a: features.require("quotesinglbase"); @@ -1055,7 +997,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const case 0x0022: { if (features.runparams().isFullUnicode() && fontspec_) features.require("textquotedblp"); - else if (fontenc_ != "T1" || internal_fontenc_) + else if (features.runparams().main_fontenc != "T1" || internal_fontenc_) features.require("textquotedbl"); break; } @@ -1079,4 +1021,28 @@ string InsetQuotes::contextMenuName() const return "context-quote"; } + +pair InsetQuotes::isWords() const +{ + int length = 1; + // In PassThru, we use straight quotes otherwise we need to check for French + if (!pass_thru_) { + + QuoteStyle style = (style_ == QuoteStyle::Dynamic) ? global_style_ : style_; + + // in French, thin spaces are added inside double guillemets + if (level_ == QuoteLevel::Primary + && (style == QuoteStyle::Swiss + || style == QuoteStyle::French + || style == QuoteStyle::FrenchIN) + && prefixIs(context_lang_, "fr")) { + // space added by default for all formats + length++; + } + } + + //one or two characters from the statistics perspective + return std::pair(length, 0); +} + } // namespace lyx