]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.C
* remove various xforms relicts, in particular:
[lyx.git] / src / buffer_funcs.C
index 2456da0c1e04095caee6e18e54ec9a6479c0a5c8..5c545cbcddc603302ed301696f09d3ab738122c7 100644 (file)
@@ -33,6 +33,7 @@
 #include "lyxvc.h"
 #include "texrow.h"
 #include "vc-backend.h"
+#include "toc.h"
 
 #include "frontends/Alert.h"
 
 #include "support/fs_extras.h"
 #include "support/lyxlib.h"
 
+#include <iostream>
+
 #include <boost/bind.hpp>
 #include <boost/filesystem/operations.hpp>
 
+using namespace std;
+
 using lyx::pit_type;
 using lyx::support::bformat;
 using lyx::support::libFileSearch;
@@ -237,7 +242,7 @@ void bufferErrors(Buffer const & buf, ErrorList const & el)
 }
 
 
-string const BufferFormat(Buffer const & buffer)
+string const bufferFormat(Buffer const & buffer)
 {
        if (buffer.isLinuxDoc())
                return "linuxdoc";
@@ -346,8 +351,8 @@ bool needEnumCounterReset(ParIterator const & it)
 }
 
 
-// set the counter of a paragraph. This includes the labels
-void setCounter(Buffer const & buf, ParIterator & it)
+// set the label of a paragraph. This includes the counters.
+void setLabel(Buffer const & buf, ParIterator & it)
 {
        Paragraph & par = *it;
        BufferParams const & bufparams = buf.params();
@@ -496,17 +501,26 @@ void setCounter(Buffer const & buf, ParIterator & it)
                }
 
                par.params().labelString(s);
-       } else
+       } else if (layout->labeltype == LABEL_NO_LABEL)
+               par.params().labelString(string());
+       else
                par.params().labelString(buf.B_(layout->labelstring()));
 }
 
 } // anon namespace
 
 
-bool needsUpdateCounters(Buffer const & buf, ParIterator & it)
+bool updateCurrentLabel(Buffer const & buf, 
+       ParIterator & it)       
 {
-       switch (it->layout()->labeltype) {
+    if (it == par_iterator_end(buf.inset()))
+        return false;
+
+//     if (it.lastpit == 0 && LyXText::isMainText())
+//             return false;
 
+       switch (it->layout()->labeltype) {
+               
        case LABEL_NO_LABEL:
        case LABEL_MANUAL:
        case LABEL_BIBLIO:
@@ -514,24 +528,53 @@ bool needsUpdateCounters(Buffer const & buf, ParIterator & it)
        case LABEL_CENTERED_TOP_ENVIRONMENT:
        case LABEL_STATIC:
        case LABEL_ITEMIZE:
-               setCounter(buf, it);
-               return false;
+               setLabel(buf, it);
+               return true;
 
        case LABEL_SENSITIVE:
        case LABEL_COUNTER:
        // do more things with enumerate later
        case LABEL_ENUMERATE:
-               return true;
+               return false;
+       }
+
+       // This is dead code which get rid of a warning:
+       return true;
+}
+
+
+void updateLabels(Buffer const & buf, 
+       ParIterator & from, ParIterator & to)
+{
+       for (ParIterator it = from; it != to; ++it) {
+               if (it.pit() > it.lastpit())
+                       return;
+               if (!updateCurrentLabel (buf, it)) {
+                       updateLabels(buf);
+                       return;
+               }
        }
 }
 
 
-void updateCounters(Buffer const & buf)
+void updateLabels(Buffer const & buf, 
+       ParIterator & iter)
 {
-       // start over
+       if (updateCurrentLabel(buf, iter))
+               return;
+
+       updateLabels(buf);
+}
+
+
+void updateLabels(Buffer const & buf)
+{
+       // start over the counters
        buf.params().getLyXTextClass().counters().reset();
+       
+       ParIterator const end = par_iterator_end(buf.inset());
 
-       for (ParIterator it = par_iterator_begin(buf.inset()); it; ++it) {
+       for (ParIterator it = par_iterator_begin(buf.inset()); it != end; ++it) {
                // reduce depth if necessary
                if (it.pit()) {
                        Paragraph const & prevpar = it.plist()[it.pit() - 1];
@@ -541,8 +584,10 @@ void updateCounters(Buffer const & buf)
                        it->params().depth(0);
 
                // set the counter for this paragraph
-               setCounter(buf, it);
+               setLabel(buf, it);
        }
+
+       lyx::toc::updateToc(buf);
 }