]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
reduce number of calls to LyXText::getFont
[lyx.git] / src / paragraph.C
index 755966eff1e815076a095c71bae089de2deaf9ee..dc5205a9e5f79dc82739d5a9763013327bc0ef44 100644 (file)
@@ -346,20 +346,23 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
 }
 
 
-lyx::pos_type Paragraph::getEndPosOfFontSpan(lyx::pos_type pos) const
+std::pair<lyx::pos_type, lyx::pos_type> Paragraph::getFontSpan(lyx::pos_type pos) const
 {
        BOOST_ASSERT(pos <= size());
+       lyx::pos_type start = 0;
 
        Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
        Pimpl::FontList::const_iterator end = pimpl_->fontlist.end();
-       for (; cit != end; ++cit)
+       for (; cit != end; ++cit) {
                if (cit->pos() >= pos)
-                       return cit->pos();
+                       return std::make_pair(start, cit->pos());
+               start = cit->pos() + 1;
+       }
 
        // This should not happen, but if so, we take no chances.
        //lyxerr << "Paragraph::getEndPosOfFontSpan: This should not happen!"
        //      << endl;
-       return pos;
+       return std::make_pair(pos, pos);
 }
 
 
@@ -578,7 +581,9 @@ int Paragraph::stripLeadingSpaces()
 
        int i = 0;
        while (!empty() && (isNewline(0) || isLineSeparator(0))) {
-               pimpl_->eraseIntern(0);
+               // Set Change::Type to Change::INSERTED to quietly remove it
+               setChange(0, Change::INSERTED);
+               erase(0);
                ++i;
        }
 
@@ -702,7 +707,7 @@ InsetBibitem * Paragraph::bibitem() const
 {
        if (!insetlist.empty()) {
                InsetBase * inset = insetlist.begin()->inset;
-               if (inset->lyxCode() == InsetBase::BIBTEX_CODE)
+               if (inset->lyxCode() == InsetBase::BIBITEM_CODE)
                        return static_cast<InsetBibitem *>(inset);
        }
        return 0;
@@ -901,9 +906,9 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
        }
 
        LyXFont basefont;
-       
+
        LaTeXFeatures features(buf, bparams, runparams.nice);
-       
+
        // output change tracking marks only if desired,
        // if dvipost is installed,
        // and with dvi/ps (other formats don't work)
@@ -1020,7 +1025,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 
                Change::Type change = pimpl_->lookupChange(i);
 
-               column += Changes::latexMarkChange(os, running_change, 
+               column += Changes::latexMarkChange(os, running_change,
                        change, output);
                running_change = change;
 
@@ -1067,7 +1072,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
 
        // Needed if there is an optional argument but no contents.
        if (body_pos > 0 && body_pos == size()) {
-               os << "]~";
+               os << "}]~";
                return_value = false;
        }
 
@@ -1878,4 +1883,3 @@ void Paragraph::dump() const
                rows_[i].dump();
        }
 }
-