]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetQuotes.cpp
Fix bug #12795
[lyx.git] / src / insets / InsetQuotes.cpp
index dc6dbba68bfabe51092ca854e944957bbea8544f..f5823605543455e820e7fec88a828ced16348efa 100644 (file)
@@ -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 = "&lsaquo;";
-               break;
-       case 0x203a: // >
-               res = "&rsaquo;";
-               break;
-       case 0x0027: // ' (plain)
-               res = "&#x27;";
-               break;
-       case 0x201e: // ,,
-               res = "&bdquo;";
-               break;
-       case 0x201d: // ''
-               res = "&rdquo;";
-               break;
-       case 0x201c: // ``
-               res = "&ldquo;";
-               break;
-       case 0x00ab: // <<
-               res = "&laquo;";
-               break;
-       case 0x00bb: // >>
-               res = "&raquo;";
-               break;
-       case 0x0022: // "
-               res = "&quot;";
-               break;
-       case 0x300c: // LEFT CORNER BRACKET
-               res = "&#x300c;";
-               break;
-       case 0x300d: // RIGHT CORNER BRACKET
-               res = "&#x300d;";
-               break;
-       case 0x300e: // LEFT WHITE CORNER BRACKET
-               res = "&#x300e;";
-               break;
-       case 0x300f: // RIGHT WHITE CORNER BRACKET
-               res = "&#x300f;";
-               break;
-       case 0x300a: // LEFT DOUBLE ANGLE BRACKET
-               res = "&#x300a;";
-               break;
-       case 0x300b: // RIGHT DOUBLE ANGLE BRACKET
-               res = "&#x300b;";
-               break;
-       case 0x3008: // LEFT ANGLE BRACKET
-               res = "&#x3008;";
-               break;
-       case 0x3009: // RIGHT ANGLE BRACKET
-               res = "&#x3009;";
-               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)
+       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
@@ -942,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")
@@ -975,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();
 }
 
@@ -1086,4 +1021,28 @@ string InsetQuotes::contextMenuName() const
        return "context-quote";
 }
 
+
+pair<int, int> 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<int,int>(length, 0);
+}
+
 } // namespace lyx