]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
Fix fuer #209
[lyx.git] / src / tabular.C
index 6e7c13aba40f293870dca2be53e1356cf1642ae9..97b1a00ad92576017d52ff6138bc6fbfd303cf8c 100644 (file)
@@ -2647,6 +2647,46 @@ InsetText * LyXTabular::GetCellInset(int row, int column) const
 }
 
 
+int LyXTabular::GetCellFromInset(Inset const * inset, int maybe_cell) const
+{
+       // is this inset part of the tabular?
+       if (!inset || inset->owner() != owner_) {
+               lyxerr[Debug::INSETTEXT]
+                       << "this is not a cell of the tabular!" << endl;
+               return -1;
+       }
+       
+       const int save_cur_cell = cur_cell;
+       int cell = cur_cell;
+       if (GetCellInset(cell) != inset) {
+               cell = maybe_cell;
+               if (cell == -1 || GetCellInset(cell) != inset) {
+                       cell = -1;
+               }
+       }
+       
+       if (cell == -1) {
+               for (cell = GetNumberOfCells(); cell >= 0; --cell) {
+                       if (GetCellInset(cell) == inset)
+                               break;
+               }
+               lyxerr[Debug::INSETTEXT]
+                        << "LyXTabular::GetCellFromInset: "
+                                   << "cell=" << cell
+                                   << ", cur_cell=" << save_cur_cell 
+                                   << ", maybe_cell=" << maybe_cell
+                                   << endl;
+               // We should have found a cell at this point
+               if (cell == -1) {
+                       lyxerr << "LyXTabular::GetCellFromInset: "
+                              << "Cell not found!" << endl;
+               }
+       }
+       
+       return cell;
+}
+
+
 void LyXTabular::Validate(LaTeXFeatures & features) const
 {
        if (IsLongTabular())