]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph_pimpl.C
Remove unused font variable which caused a warning.
[lyx.git] / src / paragraph_pimpl.C
index 37f71b1569420b61457dcf38440773a6069dbe9c..182d1165d8d0ef30ff42ea336bdcc7fceae94236 100644 (file)
@@ -39,12 +39,17 @@ Paragraph::Pimpl::Pimpl(Paragraph * owner)
 }
 
 
-Paragraph::Pimpl::Pimpl(Paragraph::Pimpl const & p, Paragraph * owner)
+Paragraph::Pimpl::Pimpl(Paragraph::Pimpl const & p, Paragraph * owner,
+                        bool same_ids)
        : params(p.params), owner_(owner)
 {
        inset_owner = p.inset_owner;
        text = p.text;
        fontlist = p.fontlist;
+       if (same_ids)
+               id_ = p.id_;
+       else
+               id_ = paragraph_id++;
 }
 
 
@@ -97,7 +102,7 @@ void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
                                                      fontlist.end(),
                                                      search_font, matchFT());
             it != fontlist.end(); ++it)
-               (*it).pos((*it).pos() + 1);
+               it->pos(it->pos() + 1);
    
        // Update the inset table.
        InsetTable search_inset(pos, 0);
@@ -105,7 +110,7 @@ void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
                                                       owner_->insetlist.end(),
                                                       search_inset, matchIT());
             it != owner_->insetlist.end(); ++it)
-               ++(*it).pos;
+               ++it->pos;
 
        owner_->setFont(pos, font);
 }
@@ -125,7 +130,7 @@ void Paragraph::Pimpl::insertInset(Paragraph::size_type pos,
        InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
                                                  owner_->insetlist.end(),
                                                  search_inset, matchIT());
-       if (it != owner_->insetlist.end() && (*it).pos == pos) {
+       if (it != owner_->insetlist.end() && it->pos == pos) {
                lyxerr << "ERROR (Paragraph::InsertInset): "
                        "there is an inset in position: " << pos << std::endl;
        } else {
@@ -148,8 +153,8 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
                        std::lower_bound(owner_->insetlist.begin(),
                                         owner_->insetlist.end(),
                                         search_inset, matchIT());
-               if (it != owner_->insetlist.end() && (*it).pos == pos) {
-                       delete (*it).inset;
+               if (it != owner_->insetlist.end() && it->pos == pos) {
+                       delete it->inset;
                        owner_->insetlist.erase(it);
                }
        }
@@ -163,10 +168,10 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
                std::lower_bound(fontlist.begin(),
                            fontlist.end(),
                            search_font, matchFT());
-       if (it != fontlist.end() && (*it).pos() == pos &&
+       if (it != fontlist.end() && it->pos() == pos &&
            (pos == 0 || 
             (it != fontlist.begin() 
-             && (*(it - 1)).pos() == pos - 1))) {
+             && boost::prior(it)->pos() == pos - 1))) {
                // If it is a multi-character font
                // entry, we just make it smaller
                // (see update below), otherwise we
@@ -184,7 +189,7 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
        // Update all other entries.
        FontList::iterator fend = fontlist.end();
        for (; it != fend; ++it)
-               (*it).pos((*it).pos() - 1);
+               it->pos(it->pos() - 1);
        
        // Update the inset table.
        InsetTable search_inset(pos, 0);
@@ -194,7 +199,7 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
                                      lend,
                                      search_inset, matchIT());
             it != lend; ++it)
-               --(*it).pos;
+               --it->pos;
 }
 
 
@@ -203,10 +208,11 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
                                       int & column, LyXFont const & font,
                                       LyXLayout const & style)
 {
+       if (style.pass_thru) return;
        if (column > tex_code_break_column
            && i 
-           && owner_->getChar(i - 1) != ' '
-           && (i < owner_->size() - 1)
+           && getChar(i - 1) != ' '
+           && (i < size() - 1)
 #ifndef NO_LATEX
            // In LaTeX mode, we don't want to
            // break lines since some commands
@@ -218,10 +224,10 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
            // In typewriter mode, we want to avoid 
            // ! . ? : at the end of a line
            && !(font.family() == LyXFont::TYPEWRITER_FAMILY
-                && (owner_->getChar(i-1) == '.'
-                    || owner_->getChar(i-1) == '?' 
-                    || owner_->getChar(i-1) == ':'
-                    || owner_->getChar(i-1) == '!'))) {
+                && (getChar(i - 1) == '.'
+                    || getChar(i - 1) == '?' 
+                    || getChar(i - 1) == ':'
+                    || getChar(i - 1) == '!'))) {
                if (tex_code_break_column == 0) {
                        // in batchmode we need LaTeX to still
                        // see it as a space not as an extra '\n'
@@ -261,6 +267,10 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                             int & column,
                                             Paragraph::value_type const c)
 {
+       if (style.pass_thru) {
+               if (c != '\0') os << c;
+               return;
+       }
        // Two major modes:  LaTeX or plain
        // Handle here those cases common to both modes
        // and then split to handle the two modes separately.
@@ -364,8 +374,8 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                        os << c;
                                        //... but we should avoid ligatures
                                        if ((c == '>' || c == '<')
-                                           && i <= owner_->size() - 2
-                                           && owner_->getChar(i + 1) == c) {
+                                           && i <= size() - 2
+                                           && getChar(i + 1) == c) {
                                                //os << "\\textcompwordmark{}";
                                                // Jean-Marc, have a look at
                                                // this. I think this works
@@ -400,8 +410,8 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                break;
 
                        case '-': // "--" in Typewriter mode -> "-{}-"
-                               if (i <= owner_->size() - 2
-                                   && owner_->getChar(i + 1) == '-'
+                               if (i <= size() - 2
+                                   && getChar(i + 1) == '-'
                                    && font.family() == LyXFont::TYPEWRITER_FAMILY) {
                                        os << "-{}";
                                        column += 2;
@@ -459,46 +469,46 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                /* idea for labels --- begin*/
                                // Check for "LyX"
                                if (c ==  'L'
-                                   && i <= owner_->size() - 3
+                                   && i <= size() - 3
                                    && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                   && owner_->getChar(i + 1) == 'y'
-                                   && owner_->getChar(i + 2) == 'X') {
+                                   && getChar(i + 1) == 'y'
+                                   && getChar(i + 2) == 'X') {
                                        os << "\\LyX{}";
                                        i += 2;
                                        column += 5;
                                }
                                // Check for "TeX"
                                else if (c == 'T'
-                                        && i <= owner_->size() - 3
+                                        && i <= size() - 3
                                         && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                        && owner_->getChar(i + 1) == 'e'
-                                        && owner_->getChar(i + 2) == 'X') {
+                                        && getChar(i + 1) == 'e'
+                                        && getChar(i + 2) == 'X') {
                                        os << "\\TeX{}";
                                        i += 2;
                                        column += 5;
                                }
                                // Check for "LaTeX2e"
                                else if (c == 'L'
-                                        && i <= owner_->size() - 7
+                                        && i <= size() - 7
                                         && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                        && owner_->getChar(i + 1) == 'a'
-                                        && owner_->getChar(i + 2) == 'T'
-                                        && owner_->getChar(i + 3) == 'e'
-                                        && owner_->getChar(i + 4) == 'X'
-                                        && owner_->getChar(i + 5) == '2'
-                                        && owner_->getChar(i + 6) == 'e') {
+                                        && getChar(i + 1) == 'a'
+                                        && getChar(i + 2) == 'T'
+                                        && getChar(i + 3) == 'e'
+                                        && getChar(i + 4) == 'X'
+                                        && getChar(i + 5) == '2'
+                                        && getChar(i + 6) == 'e') {
                                        os << "\\LaTeXe{}";
                                        i += 6;
                                        column += 8;
                                }
                                // Check for "LaTeX"
                                else if (c == 'L'
-                                        && i <= owner_->size() - 5
+                                        && i <= size() - 5
                                         && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                        && owner_->getChar(i + 1) == 'a'
-                                        && owner_->getChar(i + 2) == 'T'
-                                        && owner_->getChar(i + 3) == 'e'
-                                        && owner_->getChar(i + 4) == 'X') {
+                                        && getChar(i + 1) == 'a'
+                                        && getChar(i + 2) == 'T'
+                                        && getChar(i + 3) == 'e'
+                                        && getChar(i + 4) == 'X') {
                                        os << "\\LaTeX{}";
                                        i += 4;
                                        column += 7;
@@ -539,3 +549,15 @@ Paragraph * Paragraph::Pimpl::TeXDeeper(Buffer const * buf,
 }
 
 
+Paragraph * Paragraph::Pimpl::getParFromID(int id) const
+{
+       InsetList::const_iterator cit = owner_->insetlist.begin();
+       InsetList::const_iterator lend = owner_->insetlist.end();
+       Paragraph * result;
+       for (; cit != lend; ++cit) {
+               if ((result = cit->inset->getParFromID(id)))
+                       return result;
+       }
+       return 0;
+}
+