]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
Routines for calculating numerical labels for BibTeX citations.
[lyx.git] / src / Text2.cpp
index 080fdc0c463e332b12ae32a7986cf1f9f0a3f164..974f9a89a1ab1241a048ae63e2457a109b7aebdf 100644 (file)
@@ -94,7 +94,7 @@ FontInfo Text::layoutFont(pit_type const pit) const
 
        FontInfo font = layout.font;
        // Realize with the fonts of lesser depth.
-       //font.realize(outerFont(pit, paragraphs()));
+       //font.realize(outerFont(pit));
        font.realize(owner_->buffer().params().getFont().fontInfo());
 
        return font;
@@ -144,7 +144,7 @@ void Text::setCharFont(pit_type pit,
                while (!layoutfont.resolved() &&
                       tp != pit_type(paragraphs().size()) &&
                       pars_[tp].getDepth()) {
-                       tp = outerHook(tp, paragraphs());
+                       tp = outerHook(tp);
                        if (tp != pit_type(paragraphs().size()))
                                layoutfont.realize(pars_[tp].layout().font);
                }
@@ -431,6 +431,32 @@ docstring Text::getStringToIndex(Cursor const & cur)
 }
 
 
+void Text::setLabelWidthStringToSequence(pit_type const par_offset,
+               docstring const & s)
+{
+       pit_type offset = par_offset;
+       // Find first of same layout in sequence
+       while (!isFirstInSequence(offset)) {
+               offset = depthHook(offset, pars_[offset].getDepth());
+       }
+
+       // now apply label width string to every par
+       // in sequence
+       pit_type const end = pars_.size();
+       depth_type const depth = pars_[offset].getDepth();
+       Layout const & layout = pars_[offset].layout();
+       for (pit_type pit = offset; pit != end; ++pit) {
+               while (pars_[pit].getDepth() > depth)
+                       ++pit;
+               if (pars_[pit].getDepth() < depth)
+                       return;
+               if (pars_[pit].layout() != layout)
+                       return;
+               pars_[pit].setLabelWidthString(s);
+       }
+}
+
+
 void Text::setParagraphs(Cursor & cur, docstring arg, bool merge) 
 {
        LASSERT(cur.text(), /**/);
@@ -452,8 +478,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
                // Do this only once for a selected range of paragraphs
                // of the same layout and depth.
                if (par.getDepth() != priordepth || par.layout() != priorlayout)
-                       setLabelWidthStringToSequence(pit, pars_,
-                                       params.labelWidthString());
+                       setLabelWidthStringToSequence(pit, params.labelWidthString());
                par.params().apply(params, par.layout());
                priordepth = par.getDepth();
                priorlayout = par.layout();
@@ -481,8 +506,8 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
                // Do this only once for a selected range of paragraphs
                // of the same layout and depth.
                if (par.getDepth() != priordepth || par.layout() != priorlayout)
-                       setLabelWidthStringToSequence(pit, pars_,
-                                       par.params().labelWidthString());
+                       setLabelWidthStringToSequence(pit,
+                               par.params().labelWidthString());
                par.params().apply(p, par.layout());
                priordepth = par.getDepth();
                priorlayout = par.layout();
@@ -523,12 +548,12 @@ void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
 
        // None of these should happen, but we're scaredy-cats
        if (pos < 0) {
-               lyxerr << "dont like -1" << endl;
+               lyxerr << "don't like -1" << endl;
                LASSERT(false, /**/);
        }
 
        if (pos > para.size()) {
-               lyxerr << "dont like 1, pos: " << pos
+               lyxerr << "don't like 1, pos: " << pos
                       << " size: " << para.size()
                       << " par: " << par << endl;
                LASSERT(false, /**/);