]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Update my email and status.
[lyx.git] / src / Text.cpp
index a2f69922032510a73c251bddf9bdcd30b61efde2..48f8c82491fc40db4c3f867a5a52fb6e7a67848f 100644 (file)
@@ -60,6 +60,7 @@
 #include "insets/InsetSpecialChar.h"
 #include "insets/InsetTabular.h"
 
+#include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
@@ -264,6 +265,17 @@ bool Text::isFirstInSequence(pit_type par_offset) const
 }
 
 
+int Text::getTocLevel(pit_type par_offset) const
+{
+       Paragraph const & par = pars_[par_offset];
+
+       if (par.layout().isEnvironment() && !isFirstInSequence(par_offset))
+               return Layout::NOT_IN_TOC;
+
+       return par.layout().toclevel;
+}
+
+
 Font const Text::outerFont(pit_type par_offset) const
 {
        depth_type par_depth = pars_[par_offset].getDepth();
@@ -1811,6 +1823,7 @@ bool Text::read(Lexer & lex,
        return res;
 }
 
+
 // Returns the current font and depth as a message.
 docstring Text::currentState(Cursor const & cur) const
 {
@@ -1955,7 +1968,15 @@ docstring Text::getPossibleLabel(Cursor const & cur) const
        if (!name.empty())
                text = name + ':' + text;
 
-       return text;
+       // We need a unique label
+       docstring label = text;
+       int i = 1;
+       while (cur.buffer()->insetLabel(label)) {
+                       label = text + '-' + convert<docstring>(i);
+                       ++i;
+               }
+
+       return label;
 }