]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph_pimpl.C
some more changes
[lyx.git] / src / paragraph_pimpl.C
index f48ffbb86642dbf971ee26967a35e2dfd0b611ea..76355805cc46f70a9c7abbb985811379a204081a 100644 (file)
@@ -90,7 +90,7 @@ void Paragraph::Pimpl::setContentsFromPar(Paragraph const * par)
 Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
 {
        // This is in the critical path for loading!
-       pos_type siz = size();
+       pos_type const siz = size();
        lyx::Assert(pos <= siz);
        // This is stronger, and I belive that this is the assertion
        // that we should really use. (Lgb)
@@ -275,19 +275,30 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow,
 }
 
 
-bool Paragraph::Pimpl::isTextAt(BufferParams const & bp,
-                               string const & str, pos_type pos)
+bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos)
 {
-       LyXFont const & font = owner_->getFont(bp, pos);
+       pos_type const len = str.length();
 
+       // is the paragraph large enough?
+       if (pos + len > size())
+               return false;
+
+       // does the wanted text start at point?
        for (string::size_type i = 0; i < str.length(); ++i) {
-               if (pos + static_cast<pos_type>(i) >= size())
-                       return false;
-               if (str[i] != getChar(pos + i))
-                       return false;
-               if (owner_->getFont(bp, pos + i) != font)
+               if (str[i] != text[pos + i])
                        return false;
        }
+
+       // is there a font change in middle of the word?
+       FontList::const_iterator cit = fontlist.begin();
+       FontList::const_iterator end = fontlist.end();
+       for (; cit != end; ++cit) {
+               if (cit->pos() >= pos)
+                       break;
+       }
+       if (cit != end && pos + len - 1 > cit->pos())
+               return false;
+
        return true;
 }
 
@@ -373,7 +384,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                        break;
 
                case '±': case '²': case '³':
-               case '×': case '÷': case '¹': 
+               case '×': case '÷': case '¹':
                case '¬': case 'µ':
                        if ((bparams.inputenc == "latin1" ||
                             bparams.inputenc == "latin9") ||
@@ -507,7 +518,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                        size_t pnr = 0;
 
                        for (; pnr < phrases_nr; ++pnr) {
-                               if (isTextAt(bparams, special_phrases[pnr][0], i)) {
+                               if (isTextAt(special_phrases[pnr][0], i)) {
                                        os << special_phrases[pnr][1];
                                        i += special_phrases[pnr][0].length() - 1;
                                        column += special_phrases[pnr][1].length() - 1;
@@ -533,7 +544,7 @@ Paragraph * Paragraph::Pimpl::TeXDeeper(Buffer const * buf,
        Paragraph * par = owner_;
 
        while (par && par->params().depth() == owner_->params().depth()) {
-               if (textclasslist[bparams.textclass][par->layout()].isEnvironment()) {
+               if (par->layout()->isEnvironment()) {
                        par = par->TeXEnvironment(buf, bparams,
                                                  os, texrow);
                } else {
@@ -573,7 +584,7 @@ LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
        while (par && par->getDepth() && !tmpfont.resolved()) {
                par = par->outerHook();
                if (par) {
-                       tmpfont.realize(tclass[par->layout()].font
+                       tmpfont.realize(par->layout()->font
 #ifdef INHERIT_LANGUAGE
                                        , bparams.language
 #endif