]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetQuotes.cpp
InsetIndex: revamp IndexEntry to handle both legacy and modern index insets; simplify...
[features.git] / src / insets / InsetQuotes.cpp
index d503e8bf9a2b35003fe4133189b4cf760d0ea54a..1882769cc0e18ece5a62faccbdb7ea2042207ed6 100644 (file)
@@ -639,11 +639,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_;
@@ -854,7 +851,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.for_search != OutputParams::NoSearch)
                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
@@ -891,7 +888,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)
@@ -905,7 +902,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
@@ -945,11 +942,20 @@ 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.for_search == OutputParams::NoSearch) {
+               docstring const str = displayString();
+               os << str;
+               return str.size();
+       }
+       else {
+               if (level_ == QuoteLevel::Primary)
+                       os << from_ascii("\"");
+               else
+                       os << from_ascii("'");
+               return 1;
+       }
 }
 
 
@@ -1008,7 +1014,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();
@@ -1028,7 +1033,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");
@@ -1065,7 +1071,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;
        }