]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
Fix MSVC warning
[lyx.git] / src / Text2.cpp
index c078e38ea9e9b1572a7736bac16c711d599d7499..ed2f3fd0bac72effaee670e743a8597f014cc4b2 100644 (file)
@@ -208,19 +208,18 @@ pit_type Text::undoSpan(pit_type pit)
 
 
 void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
-               docstring const & layout)
+                    docstring const & layout)
 {
        LASSERT(start != end, /**/);
 
-       BufferParams const & bufparams = buffer.params();
-       Layout const & lyxlayout = bufparams.documentClass()[layout];
+       BufferParams const & bp = buffer.params();
+       Layout const & lyxlayout = bp.documentClass()[layout];
 
        for (pit_type pit = start; pit != end; ++pit) {
                Paragraph & par = pars_[pit];
                par.applyLayout(lyxlayout);
                if (lyxlayout.margintype == MARGIN_MANUAL)
-                       par.setLabelWidthString(par.translateIfPossible(
-                               lyxlayout.labelstring(), buffer.params()));
+                       par.setLabelWidthString(par.expandLabel(lyxlayout, bp));
        }
 }
 
@@ -392,8 +391,8 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
        // Try implicit word selection
        // If there is a change in the language the implicit word selection
        // is disabled.
-       CursorSlice resetCursor = cur.top();
-       bool implicitSelection =
+       CursorSlice const resetCursor = cur.top();
+       bool const implicitSelection =
                font.language() == ignore_language
                && font.fontInfo().number() == FONT_IGNORE
                && selectWordWhenUnderCursor(cur, WHOLE_WORD_STRICT);
@@ -444,12 +443,23 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
 
        //FIXME UNICODE
        string const argument = to_utf8(arg);
+       depth_type priordepth = -1;
+       Layout priorlayout;
        for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
             pit <= end; ++pit) {
                Paragraph & par = pars_[pit];
                ParagraphParameters params = par.params();
                params.read(argument, merge);
+               // Changes to label width string apply to all paragraphs
+               // with same layout in a sequence.
+               // 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());
                par.params().apply(params, par.layout());
+               priordepth = par.getDepth();
+               priorlayout = par.layout();
        }
 }
 
@@ -464,11 +474,22 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
        pit_type undopit = undoSpan(cur.selEnd().pit());
        recUndo(cur, cur.selBegin().pit(), undopit - 1);
 
+       depth_type priordepth = -1;
+       Layout priorlayout;
        for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
             pit <= end; ++pit) {
                Paragraph & par = pars_[pit];
+               // Changes to label width string apply to all paragraphs
+               // with same layout in a sequence.
+               // 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());
                par.params().apply(p, par.layout());
-       }       
+               priordepth = par.getDepth();
+               priorlayout = par.layout();
+       }
 }
 
 
@@ -573,7 +594,7 @@ bool Text::checkAndActivateInset(Cursor & cur, bool front)
        if (!front && cur.pos() == 0)
                return false;
        Inset * inset = front ? cur.nextInset() : cur.prevInset();
-       if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE)
+       if (!inset || !inset->editable())
                return false;
        /*
         * Apparently, when entering an inset we are expected to be positioned
@@ -599,7 +620,7 @@ bool Text::checkAndActivateInsetVisual(Cursor & cur, bool movingForward, bool mo
                return false;
        Paragraph & par = cur.paragraph();
        Inset * inset = par.isInset(cur.pos()) ? par.getInset(cur.pos()) : 0;
-       if (!inset || inset->editable() != Inset::HIGHLY_EDITABLE)
+       if (!inset || !inset->editable())
                return false;
        inset->edit(cur, movingForward, 
                movingLeft ? Inset::ENTRY_DIRECTION_RIGHT : Inset::ENTRY_DIRECTION_LEFT);
@@ -810,7 +831,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
        // Whether a common inset is found and whether the cursor is still in 
        // the same paragraph (possibly nested).
-       bool same_par = depth < cur.depth() && old.pit() == cur[depth].pit();
+       bool const same_par = depth < cur.depth() && old.pit() == cur[depth].pit();
        bool const same_par_pos = depth == cur.depth() - 1 && same_par 
                && old.pos() == cur[depth].pos();