+
+Paragraph * InsetTabular::getParFromID(int id) const
+{
+ Paragraph * result;
+ for(int i = 0; i < tabular->rows(); ++i) {
+ for(int j = 0; j < tabular->columns(); ++j) {
+ if ((result = tabular->GetCellInset(i, j)->getParFromID(id)))
+ return result;
+ }
+ }
+ return 0;
+}
+
+
+Paragraph * InsetTabular::firstParagraph() const
+{
+ if (the_locking_inset)
+ return the_locking_inset->firstParagraph();
+ return 0;
+}
+
+
+Paragraph * InsetTabular::getFirstParagraph(int i) const
+{
+ return (i < tabular->GetNumberOfCells())
+ ? tabular->GetCellInset(i)->getFirstParagraph(0)
+ : 0;
+}
+
+
+LyXCursor const & InsetTabular::cursor(BufferView * bv) const
+{
+ if (the_locking_inset)
+ return the_locking_inset->cursor(bv);
+ return Inset::cursor(bv);
+}
+
+
+Inset * InsetTabular::getInsetFromID(int id_arg) const
+{
+ if (id_arg == id())
+ return const_cast<InsetTabular *>(this);
+
+ Inset * result;
+ for(int i=0; i < tabular->rows(); ++i) {
+ for(int j=0; j < tabular->columns(); ++j) {
+ if ((result = tabular->GetCellInset(i, j)->getInsetFromID(id_arg)))
+ return result;
+ }
+ }
+ return 0;
+}
+
+
+string const InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
+{
+ if (the_locking_inset) {
+ string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
+ if (!str.empty())
+ return str;
+ if (tabular->IsLastCell(actcell)) {
+ bv->unlockInset(const_cast<InsetTabular *>(this));
+ return string();
+ }
+ ++actcell;
+ }
+ nodraw(true);
+ // otherwise we have to lock the next inset and ask for it's selecttion
+ UpdatableInset * inset =
+ static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
+ inset->edit(bv, 0, 0, 0);
+ string const str(selectNextWordInt(bv, value));
+ nodraw(false);
+ if (!str.empty())
+ resetPos(bv);
+ return str;
+}
+
+
+string InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
+{
+ // when entering this function the inset should be ALWAYS locked!
+ lyx::Assert(the_locking_inset);
+
+ string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
+ if (!str.empty())
+ return str;
+
+ if (tabular->IsLastCell(actcell)) {
+ bv->unlockInset(const_cast<InsetTabular *>(this));
+ return string();
+ }
+
+ // otherwise we have to lock the next inset and ask for it's selecttion
+ UpdatableInset * inset =
+ static_cast<UpdatableInset*>(tabular->GetCellInset(++actcell));
+ inset->edit(bv);
+ return selectNextWordInt(bv, value);
+}
+
+
+void InsetTabular::selectSelectedWord(BufferView * bv)
+{
+ if (the_locking_inset) {
+ the_locking_inset->selectSelectedWord(bv);
+ return;
+ }
+ return;
+}
+
+
+void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
+{
+ if (the_locking_inset) {
+ the_locking_inset->toggleSelection(bv, kill_selection);
+ }
+}
+
+
+bool InsetTabular::searchForward(BufferView * bv, string const & str,
+ bool const & cs, bool const & mw)
+{
+ if (the_locking_inset) {
+ if (the_locking_inset->searchForward(bv, str, cs, mw))
+ return true;
+ if (tabular->IsLastCell(actcell)) {
+ bv->unlockInset(const_cast<InsetTabular *>(this));
+ return false;
+ }
+ ++actcell;
+ }
+ // otherwise we have to lock the next inset and search there
+ UpdatableInset * inset =
+ static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
+ inset->edit(bv);
+#if 0
+ bool const res = searchForward(bv, str, cs, mw);
+ updateLocal(bv, NONE, false);
+ bv->updateInset(const_cast<InsetTabular *>(this), false);
+ return res;
+#else
+ return searchForward(bv, str, cs, mw);
+#endif
+}
+
+
+bool InsetTabular::searchBackward(BufferView * bv, string const & str,
+ bool const & cs, bool const & mw)
+{
+ if (the_locking_inset) {
+ if (the_locking_inset->searchBackward(bv, str, cs, mw))
+ return true;
+ if (!actcell) { // we are already in the first cell
+ bv->unlockInset(const_cast<InsetTabular *>(this));
+ return false;
+ }
+ --actcell;
+ }
+ // otherwise we have to lock the next inset and search there
+ UpdatableInset * inset =
+ static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
+ inset->edit(bv, false);
+#if 0
+ bool const res = searchBackward(bv, str, cs, mw);
+ bv->updateInset(const_cast<InsetTabular *>(this), false);
+ return res;
+#else
+ return searchBackward(bv, str, cs, mw);
+#endif
+}
+
+
+bool InsetTabular::insetAllowed(Inset::Code code) const
+{
+ if (the_locking_inset)
+ return the_locking_inset->insetAllowed(code);
+ return false;
+}