X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetQuotes.cpp;h=f5823605543455e820e7fec88a828ced16348efa;hb=8124e6c02ea1fd6779bb6c47ffe2bca2c8bd2d97;hp=1882769cc0e18ece5a62faccbdb7ea2042207ed6;hpb=c2229d388b622a65029d0566f5eca53b43d92528;p=lyx.git diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp index 1882769cc0..f582360554 100644 --- a/src/insets/InsetQuotes.cpp +++ b/src/insets/InsetQuotes.cpp @@ -470,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. @@ -851,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 || runparams.for_search != OutputParams::NoSearch) + 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 @@ -944,7 +871,7 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const int InsetQuotes::plaintext(odocstringstream & os, OutputParams const & op, size_t) const { - if (op.for_search == OutputParams::NoSearch) { + if (!op.find_effective()) { docstring const str = displayString(); os << str; return str.size(); @@ -959,11 +886,10 @@ int InsetQuotes::plaintext(odocstringstream & os, } -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") @@ -984,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(); } @@ -1095,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