]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.C
Whitespace cleanup.
[lyx.git] / src / buffer_funcs.C
index 1df2d55bd64b0637e2e5aeb70c916be3f6fb1c90..d616fc79da1df77bd293ae25e419313d00fbcaca 100644 (file)
 #include "Floating.h"
 #include "FloatList.h"
 #include "gettext.h"
+#include "language.h"
 #include "LaTeX.h"
 #include "lyxtextclass.h"
 #include "paragraph.h"
 #include "paragraph_funcs.h"
-#include "ParagraphList_fwd.h"
+#include "ParagraphList.h"
 #include "ParagraphParameters.h"
 #include "pariterator.h"
 #include "lyxvc.h"
@@ -214,13 +215,15 @@ void bufferErrors(Buffer const & buf, TeXErrors const & terr)
                int id_start = -1;
                int pos_start = -1;
                int errorrow = cit->error_in_line;
-               buf.texrow().getIdFromRow(errorrow, id_start, pos_start);
+               bool found = 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);
+                       found = buf.texrow().getIdFromRow(errorrow, id_end,
+                                                         pos_end);
+               } while (found && id_start == id_end && pos_start == pos_end);
 
                buf.error(ErrorItem(cit->error_desc, cit->error_text,
                                    id_start, pos_start, pos_end));
@@ -274,7 +277,7 @@ namespace {
 lyx::depth_type getDepth(DocIterator const & it)
 {
        lyx::depth_type depth = 0;
-       for (size_t i = 0 ; i < it.depth() ; ++i) 
+       for (size_t i = 0 ; i < it.depth() ; ++i)
                if (!it[i].inset().inMathed())
                        depth += it[i].paragraph().getDepth() + 1;
        // remove 1 since the outer inset does not count
@@ -282,12 +285,12 @@ lyx::depth_type getDepth(DocIterator const & it)
 }
 
 lyx::depth_type getItemDepth(ParIterator const & it)
-{      
+{
        Paragraph const & par = *it;
        LYX_LABEL_TYPES const labeltype = par.layout()->labeltype;
 
        if (labeltype != LABEL_ENUMERATE && labeltype != LABEL_ITEMIZE)
-               return 0;
+               return 0;
 
        // this will hold the lowest depth encountered up to now.
        lyx::depth_type min_depth = getDepth(it);
@@ -303,12 +306,12 @@ lyx::depth_type getItemDepth(ParIterator const & it)
                                return 0;
                        }
                }
-               
+
                // We search for the first paragraph with same label
                // that is not more deeply nested.
                Paragraph & prev_par = *prev_it;
                lyx::depth_type const prev_depth = getDepth(prev_it);
-               if (labeltype == prev_par.layout()->labeltype) {
+               if (labeltype == prev_par.layout()->labeltype) {
                        if (prev_depth < min_depth) {
                                return prev_par.itemdepth + 1;
                        }
@@ -437,7 +440,27 @@ void setCounter(Buffer const & buf, ParIterator & it)
 
                counters.step(enumcounter);
 
-               par.params().labelString(counters.enumLabel(enumcounter));
+               string format;
+
+               switch (par.itemdepth) {
+               case 0:
+                       format = N_("\\arabic{enumi}.");
+                       break;
+               case 1:
+                       format = N_("(\\alph{enumii})");
+                       break;
+               case 2:
+                       format = N_("\\roman{enumiii}.");
+                       break;
+               case 3:
+                       format = N_("\\Alph{enumiv}.");
+                       break;
+               default:
+                       // not a valid enumdepth...
+                       break;
+               }
+
+               par.params().labelString(counters.counterLabel(buf.B_(format)));
        } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
                counters.step("bibitem");
                int number = counters.value("bibitem");
@@ -453,9 +476,10 @@ 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;
+                       }
                }
 
                string s;
@@ -521,5 +545,3 @@ string expandLabel(Buffer const & buf,
 
        return tclass.counters().counterLabel(fmt);
 }
-
-