]> 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 2c941a762a29427b6767c54849187292b3fe8986..182d1165d8d0ef30ff42ea336bdcc7fceae94236 100644 (file)
@@ -39,12 +39,17 @@ Paragraph::Pimpl::Pimpl(Paragraph * owner)
 }
 
 
-Paragraph::Pimpl::Pimpl(Paragraph::Pimpl const & p, Paragraph * owner)
-       : owner_(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++;
 }
 
 
@@ -93,19 +98,19 @@ void Paragraph::Pimpl::insertChar(Paragraph::size_type pos,
 
        // Update the font table.
        FontTable search_font(pos, LyXFont());
-       for (FontList::iterator it = lower_bound(fontlist.begin(),
-                                                fontlist.end(),
-                                                search_font, matchFT());
+       for (FontList::iterator it = std::lower_bound(fontlist.begin(),
+                                                     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);
-       for (InsetList::iterator it = lower_bound(owner_->insetlist.begin(),
-                                                 owner_->insetlist.end(),
-                                                 search_inset, matchIT());
+       for (InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
+                                                      owner_->insetlist.end(),
+                                                      search_inset, matchIT());
             it != owner_->insetlist.end(); ++it)
-               ++(*it).pos;
+               ++it->pos;
 
        owner_->setFont(pos, font);
 }
@@ -122,10 +127,10 @@ void Paragraph::Pimpl::insertInset(Paragraph::size_type pos,
        
        // Add a new entry in the inset table.
        InsetTable search_inset(pos, 0);
-       InsetList::iterator it = lower_bound(owner_->insetlist.begin(),
-                                            owner_->insetlist.end(),
-                                            search_inset, matchIT());
-       if (it != owner_->insetlist.end() && (*it).pos == pos) {
+       InsetList::iterator it = std::lower_bound(owner_->insetlist.begin(),
+                                                 owner_->insetlist.end(),
+                                                 search_inset, matchIT());
+       if (it != owner_->insetlist.end() && it->pos == pos) {
                lyxerr << "ERROR (Paragraph::InsertInset): "
                        "there is an inset in position: " << pos << std::endl;
        } else {
@@ -145,11 +150,11 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
                // find the entry
                InsetTable search_inset(pos, 0);
                InsetList::iterator it =
-                       lower_bound(owner_->insetlist.begin(),
-                                   owner_->insetlist.end(),
-                                   search_inset, matchIT());
-               if (it != owner_->insetlist.end() && (*it).pos == pos) {
-                       delete (*it).inset;
+                       std::lower_bound(owner_->insetlist.begin(),
+                                        owner_->insetlist.end(),
+                                        search_inset, matchIT());
+               if (it != owner_->insetlist.end() && it->pos == pos) {
+                       delete it->inset;
                        owner_->insetlist.erase(it);
                }
        }
@@ -160,13 +165,13 @@ void Paragraph::Pimpl::erase(Paragraph::size_type pos)
        FontTable search_font(pos, LyXFont());
        
        FontList::iterator it =
-               lower_bound(fontlist.begin(),
+               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,17 +189,17 @@ 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);
        InsetList::iterator lend = owner_->insetlist.end();
        for (InsetList::iterator it =
-                    upper_bound(owner_->insetlist.begin(),
-                                lend,
-                                search_inset, matchIT());
+                    std::upper_bound(owner_->insetlist.begin(),
+                                     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.
@@ -271,15 +281,15 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                        bool close = false;
                        int const len = os.tellp();
                        //ostream::pos_type const len = os.tellp();
-                       if ((inset->LyxCode() == Inset::GRAPHICS_CODE
-                            || inset->LyxCode() == Inset::MATH_CODE
-                            || inset->LyxCode() == Inset::URL_CODE)
+                       if ((inset->lyxCode() == Inset::GRAPHICS_CODE
+                            || inset->lyxCode() == Inset::MATH_CODE
+                            || inset->lyxCode() == Inset::URL_CODE)
                            && running_font.isRightToLeft()) {
                                os << "\\L{";
                                close = true;
                        }
 
-                       int tmp = inset->Latex(buf, os, moving_arg,
+                       int tmp = inset->latex(buf, os, moving_arg,
                                               style.free_spacing);
 
                        if (close)
@@ -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;
+}
+