]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
More fixes to insettabular/text (and some missing features added).
[lyx.git] / src / tabular.C
index d61744c02d8a58aca3c80ae160a5ac918ad14ce4..707c9c353f39c211cde04a86522145f351294d97 100644 (file)
@@ -92,7 +92,9 @@ LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
 {
     owner_ = inset;
     Init(lt.rows_, lt.columns_);
+#ifdef WITH_WARNINGS
 #warning Jürgen, can you make it the other way round. So that copy assignment depends on the copy constructor and not the other way. (Lgb)
+#endif
     operator=(lt);
 }
 
@@ -321,29 +323,6 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
     rowofcell.resize(numberofcells);
     columnofcell.resize(numberofcells);
 
-#if 0
-    int row = 0;
-    int column = 0;
-    int c = 0;
-    
-    while (c < numberofcells && row < rows_ && column < columns_) {
-       rowofcell[c] = row;
-       columnofcell[c] = column;
-       ++c;
-       do {
-           ++column;
-       } while (column < columns_ &&
-                cell_info[row][column].multicolumn
-                == LyXTabular::CELL_PART_OF_MULTICOLUMN);
-       if (column == columns_) {
-           column = 0;
-           ++row;
-       }
-    }
-#else
-    // Isn't this the same as the while above? (Lgb)
-#warning Please check this Jürgen.
-    // if ok please delete the #if 0 section above. (Lgb)
     for (int row = 0, column = 0, c = 0;
         c < numberofcells && row < rows_ && column < columns_;) {
        rowofcell[c] = row;
@@ -359,7 +338,6 @@ void LyXTabular::set_row_column_number_info(bool oldformat)
            ++row;
        }
     }
-#endif
 
     for (int row = 0; row < rows_; ++row) {
        for (int column = 0; column < columns_; ++column) {
@@ -1459,7 +1437,7 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
                par->InsertChar(i, ' ');
            }
        }
-       par->CopyIntoMinibuffer(owner_->BufferOwner()->params, i);
+       par->CopyIntoMinibuffer(*owner_->BufferOwner(), i);
        inset->par->InsertFromMinibuffer(inset->par->Last());
     }
     delete par;
@@ -2030,8 +2008,8 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
     }
     if (IsMultiColumn(cell)) {
        os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
-       if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
-           os << cellinfo_of_cell(cell+1)->align_special << "}{";
+       if (!cellinfo_of_cell(cell)->align_special.empty()) {
+           os << cellinfo_of_cell(cell)->align_special << "}{";
        } else {
            if (LeftLine(cell))
                os << '|';
@@ -2374,25 +2352,16 @@ int LyXTabular::AsciiTopHLine(ostream & os, int row,
 {
     int const fcell = GetFirstCellInRow(row);
     int const n = NumberOfCellsInRow(fcell) + fcell;
-
-#if 0
     int tmp = 0;
 
     for (int i = fcell; i < n; ++i) {
-       if (TopLine(i))
+       if (TopLine(i)) {
            ++tmp;
+           break;
+       }
     }
     if (!tmp)
        return 0;
-#else
-    // Isn't this equivalent? (Lgb)
-#warning Please check this Jürgen.
-    // If ok please delete the abofe #if 0 section. (Lgb)
-    for (int i = fcell; i < n; ++i) {
-           if (TopLine(i))
-                   return 0;
-    }
-#endif
 
     unsigned char ch;
     for (int i = fcell; i < n; ++i) {
@@ -2430,25 +2399,17 @@ int LyXTabular::AsciiBottomHLine(ostream & os, int row,
 {
     int const fcell = GetFirstCellInRow(row);
     int const n = NumberOfCellsInRow(fcell) + fcell;
-
-#if 0
     int tmp = 0;
 
     for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i))
+       if (BottomLine(i)) {
            ++tmp;
+           break;
+       }
     }
     if (!tmp)
        return 0;
-#else
-    // Isn't this equivalent? (Lgb)
-#warning Please check this Jürgen.
-    // If ok, please delete the above #if 0 section. (Lgb)
-    for (int i = fcell; i < n; ++i) {
-       if (BottomLine(i))
-           return 0;
-    }
-#endif
+
     unsigned char ch;
     for (int i = fcell; i < n; ++i) {
        if (BottomLine(i)) {
@@ -2587,6 +2548,12 @@ InsetText * LyXTabular::GetCellInset(int cell) const
 }
 
 
+InsetText * LyXTabular::GetCellInset(int row, int column) const
+{
+    return GetCellInset(GetCellNumber(row, column));
+}
+
+
 void LyXTabular::Validate(LaTeXFeatures & features) const
 {
     if (IsLongTabular())