]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Clarify "Save compressed by default" feature (bug 7822)
[lyx.git] / src / Paragraph.cpp
index b0fd796f47e0927b2e879155efe7b3734f975108..a69169c41e3773f711297e982ac2949c2b8a4f16 100644 (file)
@@ -363,13 +363,6 @@ public:
                otexstream & os,
                pos_type i,
                unsigned int & column);
-       ///
-       bool latexSpecialPhrase(
-               otexstream & os,
-               pos_type & i,
-               pos_type end_pos,
-               unsigned int & column,
-               OutputParams const & runparams);
 
        ///
        void validate(LaTeXFeatures & features) const;
@@ -378,9 +371,6 @@ public:
        bool onlyText(Buffer const & buf, Font const & outerfont,
                      pos_type initial) const;
 
-       /// match a string against a particular point in the paragraph
-       bool isTextAt(string const & str, pos_type pos) const;
-
        /// a vector of speller skip positions
        typedef vector<FontSpan> SkipPositions;
        typedef SkipPositions::const_iterator SkipPositionsIterator;
@@ -508,26 +498,6 @@ public:
 };
 
 
-namespace {
-
-struct special_phrase {
-       string phrase;
-       docstring macro;
-       bool builtin;
-};
-
-special_phrase const special_phrases[] = {
-       { "LyX", from_ascii("\\LyX{}"), false },
-       { "TeX", from_ascii("\\TeX{}"), true },
-       { "LaTeX2e", from_ascii("\\LaTeXe{}"), true },
-       { "LaTeX", from_ascii("\\LaTeX{}"), true },
-};
-
-size_t const phrases_nr = sizeof(special_phrases)/sizeof(special_phrase);
-
-} // namespace anon
-
-
 Paragraph::Private::Private(Paragraph * owner, Layout const & layout)
        : owner_(owner), inset_owner_(0), id_(-1), begin_of_body_(0), layout_(&layout)
 {
@@ -1010,26 +980,6 @@ int Paragraph::Private::writeScriptChars(otexstream & os,
 }
 
 
-bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const
-{
-       pos_type const len = str.length();
-
-       // is the paragraph large enough?
-       if (pos + len > int(text_.size()))
-               return false;
-
-       // does the wanted text start at point?
-       for (string::size_type i = 0; i < str.length(); ++i) {
-               // Caution: direct comparison of characters works only
-               // because str is pure ASCII.
-               if (str[i] != text_[pos + i])
-                       return false;
-       }
-
-       return fontlist_.hasChangeInRange(pos, len);
-}
-
-
 void Paragraph::Private::latexInset(BufferParams const & bparams,
                                    otexstream & os,
                                    OutputParams & runparams,
@@ -1189,7 +1139,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
        char_type const c = (runparams.use_polyglossia) ?
                owner_->getUChar(bparams, i) : text_[i];
 
-       if (style.pass_thru || runparams.pass_thru) {
+       if (style.pass_thru || runparams.pass_thru
+           || contains(style.pass_thru_chars, c)
+           || contains(runparams.pass_thru_chars, c)) {
                if (c != '\0') {
                        Encoding const * const enc = runparams.encoding;
                        if (enc && !enc->encodable(c))
@@ -1204,10 +1156,11 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                return;
        // If T1 font encoding is used, use the special
        // characters it provides.
-       // NOTE: some languages reset the font encoding
-       // internally
+       // NOTE: Some languages reset the font encoding internally.
+       //       If we are using such a language, we do not output
+       //       special T1 chars.
        if (!runparams.inIPA && !running_font.language()->internalFontEncoding()
-           && lyxrc.fontenc == "T1" && latexSpecialT1(c, os, i, column))
+           && bparams.font_encoding() == "T1" && latexSpecialT1(c, os, i, column))
                return;
 
        // Otherwise, we use what LaTeX provides us.
@@ -1281,10 +1234,6 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                break;
 
        default:
-               // LyX, LaTeX etc.
-               if (latexSpecialPhrase(os, i, end_pos, column, runparams))
-                       return;
-
                if (c == '\0')
                        return;
 
@@ -1397,33 +1346,6 @@ bool Paragraph::Private::latexSpecialT3(char_type const c, otexstream & os,
 }
 
 
-/// \param end_pos
-///   If [start_pos, end_pos) does not include entirely the special phrase, then
-///   do not apply the macro transformation.
-bool Paragraph::Private::latexSpecialPhrase(otexstream & os, pos_type & i, pos_type end_pos,
-       unsigned int & column, OutputParams const & runparams)
-{
-       // FIXME: if we have "LaTeX" with a font
-       // change in the middle (before the 'T', then
-       // the "TeX" part is still special cased.
-       // Really we should only operate this on
-       // "words" for some definition of word
-
-       for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
-               if (!isTextAt(special_phrases[pnr].phrase, i)
-                   || (end_pos != -1 && i + int(special_phrases[pnr].phrase.size()) > end_pos))
-                       continue;
-               if (runparams.moving_arg)
-                       os << "\\protect";
-               os << special_phrases[pnr].macro;
-               i += special_phrases[pnr].phrase.length() - 1;
-               column += special_phrases[pnr].macro.length() - 1;
-               return true;
-       }
-       return false;
-}
-
-
 void Paragraph::Private::validate(LaTeXFeatures & features) const
 {
        if (layout_->inpreamble && inset_owner_) {
@@ -1501,13 +1423,6 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
 
        // then the contents
        for (pos_type i = 0; i < int(text_.size()) ; ++i) {
-               for (size_t pnr = 0; pnr < phrases_nr; ++pnr) {
-                       if (!special_phrases[pnr].builtin
-                           && isTextAt(special_phrases[pnr].phrase, i)) {
-                               features.require(special_phrases[pnr].phrase);
-                               break;
-                       }
-               }
                BufferEncodings::validate(text_[i], features);
        }
 }
@@ -2223,8 +2138,12 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
 {
        int column = 0;
 
-       if (params_.noindent() && !layout_->pass_thru
-           && (layout_->toggle_indent != ITOGGLE_NEVER)) {
+       bool canindent =
+               (bparams.paragraph_separation == BufferParams::ParagraphIndentSeparation) ?
+                       (layout_->toggle_indent != ITOGGLE_NEVER) :
+                       (layout_->toggle_indent == ITOGGLE_ALWAYS);
+
+       if (canindent && params_.noindent() && !layout_->pass_thru) {
                os << "\\noindent ";
                column += 10;
        }