]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.C
Fix bug 886 and others not reported related with the document paper size.
[lyx.git] / src / buffer_funcs.C
index 057be070d7e6639f621d2e1b129f443c9631e365..2aee55c78e46fdcff8ebad41570bd9eaecec3f8f 100644 (file)
@@ -26,6 +26,7 @@
 #include "LaTeX.h"
 #include "lyxtextclass.h"
 #include "paragraph.h"
+#include "paragraph_funcs.h"
 #include "ParagraphList_fwd.h"
 #include "ParagraphParameters.h"
 #include "pariterator.h"
@@ -211,15 +212,19 @@ void bufferErrors(Buffer const & buf, TeXErrors const & terr)
        TeXErrors::Errors::const_iterator end = terr.end();
 
        for (; cit != end; ++cit) {
-               int par_id = -1;
-               int posstart = -1;
-               int const errorrow = cit->error_in_line;
-               buf.texrow().getIdFromRow(errorrow, par_id, posstart);
-               int posend = -1;
-               buf.texrow().getIdFromRow(errorrow + 1, par_id, posend);
-               buf.error(ErrorItem(cit->error_desc,
-                                        cit->error_text,
-                                        par_id, posstart, posend));
+               int id_start = -1;
+               int pos_start = -1;
+               int errorrow = cit->error_in_line;
+               buf.texrow().getIdFromRow(errorrow, id_start, pos_start);
+               int id_end = -1;
+               int pos_end = -1;
+               do {
+                       ++errorrow;
+                       buf.texrow().getIdFromRow(errorrow, id_end, pos_end);
+               } while (id_start == id_end && pos_start == pos_end);
+
+               buf.error(ErrorItem(cit->error_desc, cit->error_text,
+                                   id_start, pos_start, pos_end));
        }
 }
 
@@ -377,9 +382,14 @@ void setCounter(Buffer const & buf, ParIterator & it)
 
        // is it a layout that has an automatic label?
        if (layout->labeltype == LABEL_COUNTER) {
-               counters.step(layout->counter);
-               string label = expandLabel(textclass, layout, par.params().appendix());
-               par.params().labelString(label);
+               if (layout->toclevel <= buf.params().secnumdepth
+                   && (layout->latextype != LATEX_ENVIRONMENT
+                       || isFirstInSequence(it.pit(), it.plist()))) {
+                       counters.step(layout->counter);
+                       string label = expandLabel(buf, layout,
+                                                  par.params().appendix());
+                       par.params().labelString(label);
+               }
        } else if (layout->labeltype == LABEL_ITEMIZE) {
                // At some point of time we should do something more
                // clever here, like:
@@ -434,10 +444,9 @@ void setCounter(Buffer const & buf, ParIterator & it)
        } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
                counters.step("bibitem");
                int number = counters.value("bibitem");
-               if (par.bibitem()) {
+               if (par.bibitem())
                        par.bibitem()->setCounter(number);
-                       par.params().labelString(layout->labelstring());
-               }
+               par.params().labelString(buf.B_(layout->labelstring()));
                // In biblio should't be following counters but...
        } else if (layout->labeltype == LABEL_SENSITIVE) {
                // Search for the first float or wrap inset in the iterator
@@ -447,7 +456,7 @@ void setCounter(Buffer const & buf, ParIterator & it)
                        --i;
                        InsetBase * const in = &it[i].inset();
                        if (in->lyxCode() == InsetBase::FLOAT_CODE
-                           || in->lyxCode() == InsetBase::WRAP_CODE) 
+                           || in->lyxCode() == InsetBase::WRAP_CODE)
                                type = in->getInsetName();
                                break;
                }
@@ -493,11 +502,13 @@ void updateCounters(Buffer const & buf)
 }
 
 
-string expandLabel(LyXTextClass const & textclass,
+string expandLabel(Buffer const & buf,
        LyXLayout_ptr const & layout, bool appendix)
 {
-       string fmt = appendix ?
-               layout->labelstring_appendix() : layout->labelstring();
+       LyXTextClass const & tclass = buf.params().getLyXTextClass();
+
+       string fmt = buf.B_(appendix ? layout->labelstring_appendix()
+                           : layout->labelstring());
 
        // handle 'inherited level parts' in 'fmt',
        // i.e. the stuff between '@' in   '@Section@.\arabic{subsection}'
@@ -506,12 +517,12 @@ string expandLabel(LyXTextClass const & textclass,
                size_t const j = fmt.find('@', i + 1);
                if (j != string::npos) {
                        string parent(fmt, i + 1, j - i - 1);
-                       string label = expandLabel(textclass, textclass[parent], appendix);
+                       string label = expandLabel(buf, tclass[parent], appendix);
                        fmt = string(fmt, 0, i) + label + string(fmt, j + 1, string::npos);
                }
        }
 
-       return textclass.counters().counterLabel(fmt);
+       return tclass.counters().counterLabel(fmt);
 }