]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Use symbols file to lookup entities for delimiters. Fixes bug #8280.
[lyx.git] / src / Paragraph.cpp
index 7053004256f6252df3483b3c92b2adaa6d34205a..c29ca4cb930110e780b8011b19ef7fea4d77a246 100644 (file)
@@ -510,6 +510,8 @@ Paragraph::Private::Private(Paragraph * owner, Layout const & layout)
 // FIXME: There should be a more intelligent way to generate and use the
 // paragraph ids per buffer instead a global static counter for all InsetText
 // in the running program.
+// However, this per-session id is used in LFUN_PARAGRAPH_GOTO to
+// switch to a different buffer, as used in the outliner for instance.
 static int paragraph_id = -1;
 
 Paragraph::Private::Private(Private const & p, Paragraph * owner)
@@ -560,6 +562,18 @@ void Paragraph::addChangesToToc(DocIterator const & cdit,
 }
 
 
+void Paragraph::addChangesToBuffer(Buffer const & buf) const
+{
+       d->changes_.updateBuffer(buf);
+}
+
+
+bool Paragraph::isChangeUpdateRequired() const
+{
+       return d->changes_.isUpdateRequired();
+}
+
+
 bool Paragraph::isDeleted(pos_type start, pos_type end) const
 {
        LASSERT(start >= 0 && start <= size(), return false);
@@ -1190,7 +1204,9 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                break;
        case '-':
                os << '-';
-               if (i + 1 < end_pos && text_[i+1] == '-') {
+               if (i + 1 < static_cast<pos_type>(text_.size()) &&
+                   (end_pos == -1 || i + 1 < end_pos) &&
+                   text_[i+1] == '-') {
                        // Prevent "--" becoming an endash and "---" becoming
                        // an emdash.
                        // Within \ttfamily, "--" is merged to "-" (no endash)
@@ -1393,7 +1409,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                                }
                        }
                        string const snippet = to_utf8(ods.str());
-                       features.addPreambleSnippet(snippet);
+                       features.addPreambleSnippet(snippet, true);
                }
        }
 
@@ -1424,7 +1440,7 @@ void Paragraph::Private::validate(LaTeXFeatures & features) const
                        icit->inset->validate(features);
                        if (layout_->needprotect &&
                            icit->inset->lyxCode() == FOOT_CODE)
-                               features.require("footmisc");
+                               features.require("NeedLyXFootnoteCode");
                }
        }
 
@@ -1729,7 +1745,10 @@ Font const & Paragraph::getFontSettings(BufferParams const & bparams,
 
 FontSpan Paragraph::fontSpan(pos_type pos) const
 {
-       LBUFERR(pos < size());
+       LBUFERR(pos <= size());
+
+       if (pos == size())
+               return FontSpan(pos, pos);
 
        pos_type start = 0;
        FontList::const_iterator cit = d->fontlist_.begin();
@@ -1818,14 +1837,6 @@ Font const Paragraph::getLayoutFont
 }
 
 
-/// Returns the height of the highest font in range
-FontSize Paragraph::highestFontInRange
-       (pos_type startpos, pos_type endpos, FontSize def_size) const
-{
-       return d->fontlist_.highestInRange(startpos, endpos, def_size);
-}
-
-
 char_type Paragraph::getUChar(BufferParams const & bparams, pos_type pos) const
 {
        char_type c = d->text_[pos];
@@ -1997,7 +2008,7 @@ docstring Paragraph::expandParagraphLabel(Layout const & layout,
                        docstring parent(fmt, i + 1, j - i - 1);
                        docstring label = from_ascii("??");
                        if (tclass.hasLayout(parent))
-                               docstring label = expandParagraphLabel(tclass[parent], bparams,
+                               label = expandParagraphLabel(tclass[parent], bparams,
                                                      process_appendix);
                        fmt = docstring(fmt, 0, i) + label
                                + docstring(fmt, j + 1, docstring::npos);
@@ -2041,14 +2052,12 @@ void Paragraph::setBeginOfBody()
        pos_type end = size();
        if (i < end && !(isNewline(i) || isEnvSeparator(i))) {
                ++i;
-               char_type previous_char = 0;
-               char_type temp = 0;
                if (i < end) {
-                       previous_char = d->text_[i];
+                       char_type previous_char = d->text_[i];
                        if (!(isNewline(i) || isEnvSeparator(i))) {
                                ++i;
                                while (i < end && previous_char != ' ') {
-                                       temp = d->text_[i];
+                                       char_type temp = d->text_[i];
                                        if (isNewline(i) || isEnvSeparator(i))
                                                break;
                                        ++i;
@@ -2195,7 +2204,6 @@ int Paragraph::Private::startTeXParParams(BufferParams const & bparams,
                        corrected_env(os, begin_tag, "flushright", code, lastpar, column);
                break;
        } case LYX_ALIGN_RIGHT: {
-               string output;
                if (owner_->getParLanguage(bparams)->babel() != "hebrew")
                        corrected_env(os, begin_tag, "flushright", code, lastpar, column);
                else
@@ -2568,8 +2576,7 @@ void Paragraph::latex(BufferParams const & bparams,
        if (allowcust && d->endTeXParParams(bparams, os, runparams)
            && runparams.encoding != prev_encoding) {
                runparams.encoding = prev_encoding;
-               if (!runparams.isFullUnicode())
-                       os << setEncoding(prev_encoding->iconvName());
+               os << setEncoding(prev_encoding->iconvName());
        }
 
        LYXERR(Debug::LATEX, "Paragraph::latex... done " << this);
@@ -3259,21 +3266,23 @@ docstring Paragraph::asString(pos_type beg, pos_type end, int options, const Out
 }
 
 
-void Paragraph::forOutliner(docstring & os, size_t maxlen) const
+void Paragraph::forOutliner(docstring & os, size_t const maxlen,
+                                                       bool const shorten) const
 {
+       size_t tmplen = shorten ? maxlen + 1 : maxlen;
        if (!d->params_.labelString().empty())
                os += d->params_.labelString() + ' ';
-       for (pos_type i = 0; i < size() && os.length() < maxlen; ++i) {
+       for (pos_type i = 0; i < size() && os.length() < tmplen; ++i) {
                if (isDeleted(i))
                        continue;
                char_type const c = d->text_[i];
                if (isPrintable(c))
                        os += c;
-               else if (c == '\t' || c == '\n')
-                       os += ' ';
                else if (c == META_INSET)
-                       getInset(i)->forOutliner(os, maxlen);
+                       getInset(i)->forOutliner(os, tmplen, false);
        }
+       if (shorten)
+               Text::shortenForOutliner(os, maxlen);
 }