In order to fix http://www.lyx.org/trac/ticket/6585 I need to check in InsetTabular if the table is inside a float.

i thought I can do this by iterating the insets starting with the table inset down to the outer insets. if one of the outer insets is a float I thought that I can say that the table is inside it. Attached is a patch where I tried this with out success.
Can anybody give me a pointer what I am doing wrong?

thanks and regards
Uwe
Index: frontends/qt4/GuiTabular.cpp
===================================================================
--- frontends/qt4/GuiTabular.cpp	(revision 35845)
+++ frontends/qt4/GuiTabular.cpp	(working copy)
@@ -176,6 +176,8 @@
 	interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
 	interlinespaceUnit->setEnabled(interlinespaceCO->currentIndex() == 2);
 
+	// setting as longtable is not allowed when table is inside a float
+	longTabularCB->setEnabled(funcEnabled(Tabular::SET_LONGTABULAR));
 	bool const longtabular = longTabularCB->isChecked();
 	longtableGB->setEnabled(true);
 	newpageCB->setEnabled(longtabular);
Index: insets/InsetTabular.cpp
===================================================================
--- insets/InsetTabular.cpp	(revision 35845)
+++ insets/InsetTabular.cpp	(working copy)
@@ -32,6 +32,7 @@
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
+#include "InsetIterator.h"
 #include "Language.h"
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
@@ -4314,6 +4315,11 @@
 			break;
 
 		case Tabular::SET_LONGTABULAR:
+			// setting as longtable is not allowed when table is inside a float
+			for (InsetIterator it = inset_iterator_begin(cur.inset()); it; ++it) {
+				if (it->lyxCode() == FLOAT_CODE)
+					status.setEnabled(false);
+			}
 			status.setOnOff(tabular.is_long_tabular);
 			break;
 

Reply via email to