]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBranch.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetBranch.cpp
index c0be8352b1790459f7b9d0beeb0a418d24f2929a..3eea5ddefb2032cce8f7cb38b608ce58620b3417 100644 (file)
@@ -25,6 +25,7 @@
 #include "Lexer.h"
 #include "OutputParams.h"
 #include "TextClass.h"
+#include "TocBackend.h"
 
 #include "support/debug.h"
 #include "support/gettext.h"
@@ -81,9 +82,8 @@ void InsetBranch::setButtonLabel()
        if (!params_.branch.empty()) {
                // FIXME UNICODE
                ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
-               if (c == Color_none) {
+               if (c == Color_none)
                        s = _("Undef: ") + s;
-               }
        }
        if (decoration() == InsetLayout::Classic)
                setLabel(isOpen() ? s : getNewLabel(s) );
@@ -94,15 +94,13 @@ void InsetBranch::setButtonLabel()
 
 ColorCode InsetBranch::backgroundColor() const
 {
-       if (!params_.branch.empty()) {
-               // FIXME UNICODE
-               ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
-               if (c == Color_none) {
-                       c = Color_error;
-               }
-               return c;
-       } else
+       if (params_.branch.empty())
                return Inset::backgroundColor();
+       // FIXME UNICODE
+       ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
+       if (c == Color_none)
+               c = Color_error;
+       return c;
 }
 
 
@@ -273,6 +271,19 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
 }
 
 
+void InsetBranch::addToToc(DocIterator const & cpit)
+{
+       DocIterator pit = cpit;
+       pit.push_back(CursorSlice(*this));
+
+       Toc & toc = buffer().tocBackend().toc("branch");
+       docstring const str = params_.branch + ": " + text().getPar(0).asString();
+       toc.push_back(TocItem(pit, 0, str));
+       // Proceed with the rest of the inset.
+       InsetCollapsable::addToToc(cpit);
+}
+
+
 void InsetBranchParams::write(ostream & os) const
 {
        os << "Branch " << to_utf8(branch) << '\n';