]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetFoot.cpp
Fix bug #10904.
[lyx.git] / src / insets / InsetFoot.cpp
index cb7462d503702c0f993f9492e4640bb47a4f9af7..1c3862635e105d59c710cbc3cdc3df575c565403 100644 (file)
@@ -17,6 +17,7 @@
 #include "BufferParams.h"
 #include "Counters.h"
 #include "Language.h"
+#include "LaTeXFeatures.h"
 #include "Layout.h"
 #include "OutputParams.h"
 #include "ParIterator.h"
@@ -33,13 +34,17 @@ using namespace std;
 namespace lyx {
 
 InsetFoot::InsetFoot(Buffer * buf)
-       : InsetFootlike(buf), intitle_(false)
+       : InsetFootlike(buf), intitle_(false), infloattable_(false)
 {}
 
 
 docstring InsetFoot::layoutName() const
 {
-       return intitle_ ? from_ascii("Foot:InTitle") : from_ascii("Foot");
+       if (intitle_)
+               return from_ascii("Foot:InTitle");
+       else if (infloattable_)
+               return from_ascii("Foot:InFloatTable");
+       return from_ascii("Foot");
 }
 
 
@@ -53,7 +58,13 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
        }
 
        intitle_ = false;
-       for (size_type sl = 0 ; sl < it.depth() ; ++ sl) {
+       infloattable_ = false;
+       bool intable = false;
+       if (it.innerInsetOfType(TABULAR_CODE) != 0)
+               intable = true;
+       if (it.innerInsetOfType(FLOAT_CODE) != 0)
+               infloattable_ = intable;
+       for (size_type sl = 0 ; sl < it.depth() ; ++sl) {
                if (it[sl].text() && it[sl].paragraph().layout().intitle) {
                        intitle_ = true;
                        break;
@@ -69,7 +80,7 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
        custom_label_ += ' ' + cnts.theCounter(count, lang->code());
        setLabel(custom_label_);
 
-       InsetCollapsable::updateBuffer(it, utype);
+       InsetCollapsible::updateBuffer(it, utype);
        if (utype == OutputUpdate)
                cnts.restoreLastCounter();
 }
@@ -79,7 +90,7 @@ docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
 {
        if (isOpen(bv))
                // this will give us something useful if there is no button
-               return InsetCollapsable::toolTip(bv, x, y);
+               return InsetCollapsible::toolTip(bv, x, y);
        return toolTipText(custom_label_+ ": ");
 }
 
@@ -104,4 +115,21 @@ int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
        return i;
 }
 
+
+void InsetFoot::validate(LaTeXFeatures & features) const
+{
+       // Use footnote package to provide footnotes in tables
+       // unless an alternative approach is built in the class.
+       if (!features.saveNoteEnv().empty()
+           && !features.isProvided("footnote-alternative")) {
+               features.require("footnote");
+               features.addPreambleSnippet(
+                       from_ascii("\\makesavenoteenv{"
+                                  + features.saveNoteEnv()
+                                  + "}\n"));
+       }
+
+       InsetText::validate(features);
+}
+
 } // namespace lyx