]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph.C
initialize footnotekind int LyXParagraph()
[lyx.git] / src / paragraph.C
index d83f3332e023de2daa01f2ae13129e8f87436f4d..b54f9b0f23c6d91244f4c224abb67794753985bf 100644 (file)
@@ -73,7 +73,8 @@ LyXParagraph::LyXParagraph()
        insettable = 0;
 #endif
        footnoteflag = LyXParagraph::NO_FOOTNOTE;
-
+       footnotekind = LyXParagraph::FOOTNOTE; // should not be needed
+       
        align = LYX_ALIGN_BLOCK;
 
        /* table stuff -- begin*/ 
@@ -142,8 +143,7 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
                                os << "\n\\begin_float "
                                   << string_footnotekinds[footnotekind]
                                   << " ";
-                       }
-                       else {
+                       } else {
                                os << "\n\\end_float ";
                        }
                }
@@ -153,13 +153,12 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
                        if (depth > dth) {
                                while (depth > dth) {
                                        os << "\n\\begin_deeper ";
-                                       dth++;
+                                       ++dth;
                                }
-                       }
-                       else {
+                       } else {
                                while (depth < dth) {
                                        os << "\n\\end_deeper ";
-                                       dth--;
+                                       --dth;
                                }
                        }
                }
@@ -233,8 +232,7 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
                         }
                        os << '\n';
                 }
-       }
-       else {
+       } else {
                // Dummy layout. This means that a footnote ended.
                os << "\n\\end_float ";
                footflag = LyXParagraph::NO_FOOTNOTE;
@@ -253,8 +251,8 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
        font1 = LyXFont(LyXFont::ALL_INHERIT);
 
        column = 0;
-       for (size_type i = 0; i < size(); i++) {
-               if (!i){
+       for (size_type i = 0; i < size(); ++i) {
+               if (!i) {
                        os << "\n";
                        column = 0;
                }
@@ -320,7 +318,7 @@ void LyXParagraph::writeFile(ostream & os, BufferParams & params,
                        else
                                lyxerr << "ERROR (LyXParagraph::writeFile):"
                                        " NULL char in structure." << endl;
-                       column++;
+                       ++column;
                        break;
                }
        }
@@ -553,14 +551,14 @@ LyXParagraph::~LyXParagraph()
        while (insettable) {
                tmpinset = insettable;
                insettable = insettable->next;
-               if (tmpinset->inset)
+               if (tmpinset->inset) // DEL LINE
                        delete tmpinset->inset;
                delete tmpinset;
                if (insettable && insettable->next == insettable) {
                        // somehow this recursion appears occasionally
                        // but I can't find where.  This bandaid
                        // helps but isn't the best fix. (ARRae)
-                       if (insettable->inset) {
+                       if (insettable->inset) { // DEL LINE
                                delete insettable->inset;
                        }
                        delete insettable;
@@ -578,12 +576,12 @@ LyXParagraph::~LyXParagraph()
 #endif
 
        /* table stuff -- begin*/ 
-       if (table)
+       if (table) // DEL LINE
                delete table;
        /* table stuff -- end*/ 
 
         // ale970302
-       if (bibkey)
+       if (bibkey) // DEL LINE
                delete bibkey;
 }
 
@@ -621,7 +619,7 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
                                tmpi = tmpi->next;
                        }
                        if (tmpi) {     // this should always be true
-                               if (tmpi->inset) // delete the inset if it exists
+                               if (tmpi->inset) // delete the inset if it exists // DEL LINE
                                        delete tmpi->inset;
                                if (tmpi == insettable)
                                        insettable = tmpi->next;
@@ -1161,7 +1159,7 @@ string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
        int firstpos = lastpos;
        
        while ((firstpos >= 0) && !IsLetter(firstpos))
-               firstpos--;
+               --firstpos;
 
        // now find the beginning by looking for a nonletter
        
@@ -1577,8 +1575,7 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar()
                tmppar = tmppar->previous;
    
        if (!tmppar) {
-               Assert(false); // let's get an abort then
-               return this; // This should never happen!
+               return this;
        } else
                return tmppar;
 }
@@ -1590,13 +1587,13 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
                return this;
        LyXParagraph const * tmppar = this;
 
-       while (tmppar && (tmppar->IsDummy()
-                         || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
+       while (tmppar &&
+              (tmppar->IsDummy()
+               || tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
                tmppar = tmppar->previous;
    
        if (!tmppar) {
-               Assert(false); // let's get an abort then
-               return this;  // This should never happen!
+               return this;
        } else
                return tmppar;
 }
@@ -1689,19 +1686,19 @@ void LyXParagraph::BreakParagraph(LyXParagraph::size_type pos,
                // to the new paragraph
                pos_first = 0;
                while (ParFromPos(pos_first) != par)
-                       pos_first++;
+                       ++pos_first;
 
                pos_end = pos_first + par->text.size() - 1;
                // The constructor has already reserved 500 elements
                //if (pos_end > pos)
                //      tmp->text.reserve(pos_end - pos);
 
-               for (i = pos; i <= pos_end; i++) {
+               for (i = pos; i <= pos_end; ++i) {
                        par->CutIntoMinibuffer(i - pos_first);
                        tmp->InsertFromMinibuffer(i - pos);
                }
                tmp->text.resize(tmp->text.size());
-               for (i = pos_end; i >= pos; i--)
+               for (i = pos_end; i >= pos; --i)
                        par->Erase(i - pos_first);
 
                par->text.resize(par->text.size());
@@ -1795,7 +1792,7 @@ LyXParagraph * LyXParagraph::Clone() const
     
        // copy everything behind the break-position to the new paragraph
    
-       for (size_type i = 0; i < size(); i++) {
+       for (size_type i = 0; i < size(); ++i) {
                CopyIntoMinibuffer(i);
                result->InsertFromMinibuffer(i);
        }
@@ -1894,10 +1891,9 @@ void LyXParagraph::PasteParagraph()
 
        size_type pos_end = the_next->text.size() - 1;
        size_type pos_insert = Last();
-       size_type i;
 
        // ok, now copy the paragraph
-       for (i = 0; i <= pos_end; i++) {
+       for (size_type i = 0; i <= pos_end; ++i) {
                the_next->CutIntoMinibuffer(i);
                InsertFromMinibuffer(pos_insert + i);
        }
@@ -2183,7 +2179,7 @@ int LyXParagraph::AutoDeleteInsets()
                tmpi = tmpi->next;
                if (tmpi2->inset) {
                        if (tmpi2->inset->AutoDelete()) {
-                               i++;
+                               ++i;
                                Erase(tmpi2->pos);
                        }
                } else {
@@ -2203,7 +2199,7 @@ Inset * LyXParagraph::ReturnNextInsetPointer(LyXParagraph::size_type & pos)
        for (InsetList::iterator it = insetlist.begin();
             it != insetlist.end(); ++it) {
                if ((*it).pos >= pos) {
-                       if (it2 != insetlist.end() || (*it).pos < (*it2).pos)
+                       if (it2 == insetlist.end() || (*it).pos < (*it2).pos)
                                it2 = it;
                }
        }
@@ -2473,10 +2469,10 @@ bool LyXParagraph::SimpleTeXOnePar(string & file, TexRow & texrow)
            && !IsDummy()) {
                if (style.isCommand()) {
                        file += '{';
-                       column++;
+                       ++column;
                } else if (align != LYX_ALIGN_LAYOUT) {
                        file += '{';
-                       column++;
+                       ++column;
                        return_value = true;
                }
        }
@@ -2677,9 +2673,9 @@ bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
 
        for (size_type i = 0; i < size(); ++i) {
                char c = GetChar(i);
-               if (table->IsContRow(current_cell_number+1)) {
+               if (table->IsContRow(current_cell_number + 1)) {
                        if (c == LyXParagraph::META_NEWLINE)
-                               current_cell_number++;
+                               ++current_cell_number;
                        continue;
                }
                ++column;
@@ -2732,9 +2728,9 @@ bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
                        }
                        basefont = getFont(-1);
                        running_font = basefont;
-                       current_cell_number++;
+                       ++current_cell_number;
                        if (table->CellHasContRow(current_cell_number) >= 0) {
-                               TeXContTableRows(file, i+1,
+                               TeXContTableRows(file, i + 1,
                                                 current_cell_number,
                                                 column, texrow);
                        }
@@ -2742,20 +2738,20 @@ bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
                        // put the EndOfCell because it is put after the
                        // for(...)
                        if (table->ShouldBeVeryLastCell(current_cell_number)) {
-                               current_cell_number--;
+                               --current_cell_number;
                                break;
                        }
                        int tmp = table->TexEndOfCell(file,
                                                      current_cell_number);
-                       if (tmp>0) {
+                       if (tmp > 0) {
                                column = 0;
                        } else if (tmp < 0) {
                                tmp = -tmp;
                        }
-                       for (;tmp--;) {
+                       for (; tmp--;) {
                                texrow.newline();
                        }
-                       texrow.start(this, i+1);
+                       texrow.start(this, i + 1);
                } else {
                        SimpleTeXSpecialChars(file, texrow,
                                              font, running_font, basefont,
@@ -2767,7 +2763,7 @@ bool LyXParagraph::SimpleTeXOneTablePar(string & file, TexRow & texrow)
        if (open_font) {
                running_font.latexWriteEndChanges(file, basefont);
        }
-       current_cell_number++;
+       ++current_cell_number;
        tmp = table->TexEndOfCell(file, current_cell_number);
        for (; tmp > 0; --tmp)
                texrow.newline();
@@ -2807,7 +2803,7 @@ bool LyXParagraph::TeXContTableRows(string & file,
                for (; (i < size()) && (current_cell_number<cell); ++i) {
                        c = GetChar(i);
                        if (c == LyXParagraph::META_NEWLINE)
-                               current_cell_number++;
+                               ++current_cell_number;
                }
                lastpos = i;
                c = GetChar(i);
@@ -2955,7 +2951,7 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
 {
        if (!table) return;
        lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar... " << this << endl;
-       int column;
+       int column = 0;
        LyXFont font1, font2;
        char c;
        Inset * inset;
@@ -3017,7 +3013,7 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                                emph_flag= false;
                        }
                        font1 = font2 = getFont(-1);
-                       current_cell_number++;
+                       ++current_cell_number;
                        if (table->CellHasContRow(current_cell_number) >= 0) {
                                DocBookContTableRows(file, extra, desc_on, i+1,
                                                     current_cell_number,
@@ -3027,11 +3023,12 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                        // put the EndOfCell because it is put after the
                        // for(...)
                        if (table->ShouldBeVeryLastCell(current_cell_number)) {
-                               current_cell_number--;
+                               --current_cell_number;
                                break;
                        }
-                       tmp= table->DocBookEndOfCell(file, current_cell_number,
-                                                    depth);
+                       tmp = table->DocBookEndOfCell(file,
+                                                     current_cell_number,
+                                                     depth);
                        
                        if (tmp > 0)
                                column = 0;
@@ -3076,7 +3073,7 @@ void LyXParagraph::SimpleDocBookOneTablePar(string & file, string & extra,
                                // non-breaking characters
                                // char is ' '
                                if (desc_on == 1) {
-                                       char_line_count++;
+                                       ++char_line_count;
                                        file += '\n';
                                        file += "</term><listitem><para>";
                                        desc_on = 2;
@@ -3159,7 +3156,7 @@ void LyXParagraph::DocBookContTableRows(string & file, string & extra,
                for (; i < size() && current_cell_number < cell; ++i) {
                        c = GetChar(i);
                        if (c == LyXParagraph::META_NEWLINE)
-                               current_cell_number++;
+                               ++current_cell_number;
                }
                lastpos = i;
                c = GetChar(i);
@@ -3229,7 +3226,7 @@ void LyXParagraph::DocBookContTableRows(string & file, string & extra,
                                        // non-breaking characters
                                        // char is ' '
                                        if (desc_on == 1) {
-                                               char_line_count++;
+                                               ++char_line_count;
                                                file += '\n';
                                                file += "</term><listitem><para>";
                                                desc_on = 2;
@@ -3319,7 +3316,7 @@ void LyXParagraph::SimpleTeXSpecialChars(string & file, TexRow & texrow,
                        } else {
                                column += file.length() - len;
                        }
-                       for (;tmp--;) {
+                       for (; tmp--;) {
                                texrow.newline();
                        }
                }