]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.cpp
SCons: msvc does not need this /TP option any more after we rename .C => .cpp. Also...
[lyx.git] / src / buffer_funcs.cpp
index 85044361a79141df1c57f597808ce4dd6bf7ddd8..8db089a47cd18c34850b8628568ed7a4ece82bc9 100644 (file)
 #include "ParIterator.h"
 #include "LyXVC.h"
 #include "TexRow.h"
+#include "Text.h"
 #include "TocBackend.h"
 #include "VCBackend.h"
 
 #include "frontends/alert.h"
 
 #include "insets/InsetBibitem.h"
-#include "insets/InsetCaption.h"
 #include "insets/InsetInclude.h"
-#include "insets/InsetTabular.h"
 
-#include "support/convert.h"
 #include "support/filetools.h"
 #include "support/fs_extras.h"
 #include "support/lyxlib.h"
@@ -432,8 +430,8 @@ void setLabel(Buffer const & buf, ParIterator & it)
                par.params().labelWidthString(docstring());
        }
 
-       // is it a layout that has an automatic label?
-       if (layout->labeltype == LABEL_COUNTER) {
+       switch(layout->labeltype) {
+       case LABEL_COUNTER:
                if (layout->toclevel <= buf.params().secnumdepth
                    && (layout->latextype != LATEX_ENVIRONMENT
                        || isFirstInSequence(it.pit(), it.plist()))) {
@@ -442,8 +440,9 @@ void setLabel(Buffer const & buf, ParIterator & it)
                                par.expandLabel(layout, buf.params()));
                } else
                        par.params().labelString(docstring());
+               break;
 
-       } else if (layout->labeltype == LABEL_ITEMIZE) {
+       case LABEL_ITEMIZE: {
                // At some point of time we should do something more
                // clever here, like:
                //   par.params().labelString(
@@ -465,10 +464,11 @@ void setLabel(Buffer const & buf, ParIterator & it)
                        break;
                }
                par.params().labelString(itemlabel);
+               break;
+       }
 
-       } else if (layout->labeltype == LABEL_ENUMERATE) {
-               // FIXME
-               // Yes I know this is a really, really! bad solution
+       case LABEL_ENUMERATE: {
+               // FIXME: Yes I know this is a really, really! bad solution
                // (Lgb)
                docstring enumcounter = from_ascii("enum");
 
@@ -517,16 +517,10 @@ void setLabel(Buffer const & buf, ParIterator & it)
                par.params().labelString(counters.counterLabel(
                        par.translateIfPossible(from_ascii(format), buf.params())));
 
-       } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
-               counters.step(from_ascii("bibitem"));
-               int number = counters.value(from_ascii("bibitem"));
-               if (par.bibitem())
-                       par.bibitem()->setCounter(number);
+               break;
+       }
 
-               par.params().labelString(
-                       par.translateIfPossible(layout->labelstring(), buf.params()));
-               // In biblio shouldn't be following counters but...
-       } else if (layout->labeltype == LABEL_SENSITIVE) {
+       case LABEL_SENSITIVE: {
                string const & type = counters.current_float();
                docstring full_label;
                if (type.empty())
@@ -537,17 +531,28 @@ void setLabel(Buffer const & buf, ParIterator & it)
                                counters.step(from_utf8(type));
                                full_label = bformat(from_ascii("%1$s %2$s:"), 
                                                     name, 
-                                                    convert<docstring>(counters.value(from_utf8(type))));
+                                                    counters.theCounter(from_utf8(type)));
                        } else
                                full_label = bformat(from_ascii("%1$s #:"), name);      
                }
                par.params().labelString(full_label);   
+               break;
+       }
 
-       } else if (layout->labeltype == LABEL_NO_LABEL)
+       case LABEL_NO_LABEL:
                par.params().labelString(docstring());
-       else
+               break;
+
+       case LABEL_MANUAL:
+       case LABEL_TOP_ENVIRONMENT:
+       case LABEL_CENTERED_TOP_ENVIRONMENT:
+       case LABEL_STATIC:      
+       case LABEL_BIBLIO:
                par.params().labelString(
-                       par.translateIfPossible(layout->labelstring(), buf.params()));
+                       par.translateIfPossible(layout->labelstring(), 
+                                               buf.params()));
+               break;
+       }
 }
 
 } // anon namespace
@@ -600,9 +605,10 @@ void updateLabels(Buffer const & buf, bool childonly)
        Buffer & cbuf = const_cast<Buffer &>(buf);
 
        if (buf.text().empty()) {
-               // FIXME: we don't call continue with updateLabels() here because
-               // it crashes on newly created documents. But the TocBackend needs to
-               // be initialised nonetheless so we update the tocBackend manually.
+               // FIXME: we don't call continue with updateLabels()
+               // here because it crashes on newly created documents.
+               // But the TocBackend needs to be initialised
+               // nonetheless so we update the tocBackend manually.
                cbuf.tocBackend().update();
                return;
        }