]> git.lyx.org Git - lyx.git/commitdiff
Make rowpainter store a ParagraphList::iterator, make some LyXText functions take...
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 9 Apr 2003 21:34:31 +0000 (21:34 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 9 Apr 2003 21:34:31 +0000 (21:34 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6748 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxtext.h
src/rowpainter.C
src/rowpainter.h
src/text.C
src/text2.C

index c8eece3e04bfaf8a4431df14b55795f3ec6859fd..0e1ff836b7760b68f2d80fa0edd577daf87bf20f 100644 (file)
@@ -1,3 +1,19 @@
+2003-04-09  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * text2.C (getFont): change to take a ParagraphList::iterator
+       instead of Paragraph*
+       Adjust several functions.
+
+       * text.C (transformChar): change to take a ParagraphList::iterator
+       instead of Paragraph*
+       (singleWidth): ditto
+       Adjust several functions.
+       
+       * rowpainter.C: adjust several functions
+       * rowpainter.h:store a ParagraphList::iterator and not a
+       Paragraph&.
+       
+
 2003-04-09  John Levon  <levon@movementarian.org>
 
        * lyxfunc.C:
index 3d533145ae93dd235b42e3a1edabb130e4d6517a..5cf8229de0a3e98f245a7be5817021a359a507eb 100644 (file)
@@ -102,7 +102,7 @@ public:
        ///
        int getRealCursorX() const;
        ///
-       LyXFont const getFont(Buffer const *, Paragraph * par,
+       LyXFont const getFont(Buffer const *, ParagraphList::iterator pit,
                lyx::pos_type pos) const;
        ///
        LyXFont const getLayoutFont(Buffer const *, Paragraph * par) const;
@@ -544,10 +544,10 @@ public:
        Inset * checkInsetHit(int & x, int & y);
 
        ///
-       int singleWidth(Paragraph * par,
+       int singleWidth(ParagraphList::iterator pit,
                lyx::pos_type pos) const;
        ///
-       int singleWidth(Paragraph * par,
+       int singleWidth(ParagraphList::iterator pit,
                lyx::pos_type pos, char c) const;
 
        /// return the color of the canvas
@@ -556,7 +556,7 @@ public:
        ///
        mutable bool bidi_same_direction;
 
-       unsigned char transformChar(unsigned char c, Paragraph * par,
+       unsigned char transformChar(unsigned char c, Paragraph const & par,
                                    lyx::pos_type pos) const;
 
        /**
index bc9f33013049c70328b51506d39be84198fc3b85..3d909313b1e775facc1a6789ac85c9bb1e652231 100644 (file)
@@ -55,43 +55,38 @@ BufferView * perv(BufferView const & bv)
 
 RowPainter::RowPainter(BufferView const & bv,
                       LyXText const & text, RowList::iterator rit)
-       : bv_(bv), pain_(bv_.painter()), text_(text), row_(rit), par_(*rit->par())
+       : bv_(bv), pain_(bv_.painter()), text_(text), row_(rit), pit_(rit->par())
 {}
 
 
 /// "temporary"
 LyXFont const RowPainter::getFont(pos_type pos) const
 {
-       Paragraph * perverted_par = const_cast<Paragraph *>(&par_);
-       return text_.getFont(bv_.buffer(), perverted_par, pos);
+       return text_.getFont(bv_.buffer(), pit_, pos);
 }
 
 
 int RowPainter::singleWidth(lyx::pos_type pos) const
 {
-       Paragraph * par(const_cast<Paragraph*>(&par_));
-       return text_.singleWidth(par, pos);
+       return text_.singleWidth(pit_, pos);
 }
 
 
 int RowPainter::singleWidth(lyx::pos_type pos, char c) const
 {
-       Paragraph * par(const_cast<Paragraph*>(&par_));
-       return text_.singleWidth(par, pos, c);
+       return text_.singleWidth(pit_, pos, c);
 }
 
 
 LyXFont const RowPainter::getLabelFont() const
 {
-       Paragraph * par(const_cast<Paragraph*>(&par_));
-       return text_.getLabelFont(bv_.buffer(), par);
+       return text_.getLabelFont(bv_.buffer(), &*pit_);
 }
 
 
 char const RowPainter::transformChar(char c, lyx::pos_type pos) const
 {
-       Paragraph * par(const_cast<Paragraph*>(&par_));
-       return text_.transformChar(c, par, pos);
+       return text_.transformChar(c, *pit_, pos);
 }
 
 
@@ -103,7 +98,7 @@ int RowPainter::leftMargin() const
 
 void RowPainter::paintInset(pos_type const pos)
 {
-       Inset * inset = const_cast<Inset*>(par_.getInset(pos));
+       Inset * inset = const_cast<Inset*>(pit_->getInset(pos));
 
        lyx::Assert(inset);
 
@@ -123,7 +118,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos)
        string str;
 
        // first char
-       char c = par_.getChar(pos);
+       char c = pit_->getChar(pos);
        str += c;
        ++vpos;
 
@@ -132,7 +127,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos)
        int dx = 0;
 
        for (pos_type i = pos - 1; i >= 0; --i) {
-               c = par_.getChar(i);
+               c = pit_->getChar(i);
                if (!Encodings::IsComposeChar_hebrew(c)) {
                        if (IsPrintableNonspace(c)) {
                                int const width2 =
@@ -157,7 +152,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
        string str;
 
        // first char
-       char c = par_.getChar(pos);
+       char c = pit_->getChar(pos);
        c = transformChar(c, pos);
        str +=c;
        ++vpos;
@@ -166,8 +161,8 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
        int const width = font_metrics::width(c, font);
        int dx = 0;
 
-       for (pos_type i = pos-1; i >= 0; --i) {
-               c = par_.getChar(i);
+       for (pos_type i = pos - 1; i >= 0; --i) {
+               c = pit_->getChar(i);
                if (!Encodings::IsComposeChar_arabic(c)) {
                        if (IsPrintableNonspace(c)) {
                                int const width2 =
@@ -190,28 +185,28 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
 
        // first character
        string str;
-       str += par_.getChar(pos);
+       str += pit_->getChar(pos);
        if (arabic) {
                unsigned char c = str[0];
                str[0] = transformChar(c, pos);
        }
 
-       bool prev_struckout(isDeletedText(par_, pos));
-       bool prev_newtext(isInsertedText(par_, pos));
+       bool prev_struckout(isDeletedText(*pit_, pos));
+       bool prev_newtext(isInsertedText(*pit_, pos));
 
        ++vpos;
 
        // collect as much similar chars as we can
        while (vpos <= last && (pos = text_.vis2log(vpos)) >= 0) {
-               char c = par_.getChar(pos);
+               char c = pit_->getChar(pos);
 
                if (!IsPrintableNonspace(c))
                        break;
 
-               if (prev_struckout != isDeletedText(par_, pos))
+               if (prev_struckout != isDeletedText(*pit_, pos))
                        break;
 
-               if (prev_newtext != isInsertedText(par_, pos))
+               if (prev_newtext != isInsertedText(*pit_, pos))
                        break;
 
                if (arabic && Encodings::IsComposeChar_arabic(c))
@@ -262,7 +257,7 @@ void RowPainter::paintFromPos(pos_type & vpos)
 
        float const orig_x = x_;
 
-       char const c = par_.getChar(pos);
+       char const c = pit_->getChar(pos);
 
        if (IsInsetChar(c)) {
                paintInset(pos);
@@ -308,7 +303,7 @@ void RowPainter::paintBackground()
 
 void RowPainter::paintSelection()
 {
-       bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
+       bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
 
        // the current selection
        int const startx = text_.selection.start.x();
@@ -358,7 +353,7 @@ void RowPainter::paintSelection()
        if ((startrow != row_ && !is_rtl) || (endrow != row_ && is_rtl))
                pain_.fillRectangle(xo_, yo_, int(x_), row_->height(), LColor::selection);
 
-       pos_type const body_pos = par_.beginningOfBody();
+       pos_type const body_pos = pit_->beginningOfBody();
        pos_type const last = lastPrintablePos(text_, row_);
        float tmpx = x_;
 
@@ -366,12 +361,12 @@ void RowPainter::paintSelection()
                pos_type pos = text_.vis2log(vpos);
                float const old_tmpx = tmpx;
                if (body_pos > 0 && pos == body_pos - 1) {
-                       LyXLayout_ptr const & layout = par_.layout();
+                       LyXLayout_ptr const & layout = pit_->layout();
                        LyXFont const lfont = getLabelFont();
 
                        tmpx += label_hfill_ + font_metrics::width(layout->labelsep, lfont);
 
-                       if (par_.isLineSeparator(body_pos - 1))
+                       if (pit_->isLineSeparator(body_pos - 1))
                                tmpx -= singleWidth(body_pos - 1);
                }
 
@@ -383,7 +378,7 @@ void RowPainter::paintSelection()
                                tmpx += label_hfill_;
                }
 
-               else if (par_.isSeparator(pos)) {
+               else if (pit_->isSeparator(pos)) {
                        tmpx += singleWidth(pos);
                        if (pos >= body_pos)
                                tmpx += separator_;
@@ -413,7 +408,7 @@ void RowPainter::paintChangeBar()
        pos_type const start = row_->pos();
        pos_type const end = lastPrintablePos(text_, row_);
 
-       if (!par_.isChanged(start, end))
+       if (!pit_->isChanged(start, end))
                return;
 
        int const height = (boost::next(row_) != text_.rows().end()
@@ -426,7 +421,7 @@ void RowPainter::paintChangeBar()
 
 void RowPainter::paintAppendix()
 {
-       if (!par_.params().appendix())
+       if (!pit_->params().appendix())
                return;
 
        // FIXME: can be just width_ ?
@@ -434,7 +429,7 @@ void RowPainter::paintAppendix()
 
        int y = yo_;
 
-       if (par_.params().startOfAppendix())
+       if (pit_->params().startOfAppendix())
                y += 2 * defaultRowHeight();
 
        pain_.line(1, y, 1, yo_ + row_->height(), LColor::appendix);
@@ -444,7 +439,7 @@ void RowPainter::paintAppendix()
 
 void RowPainter::paintDepthBar()
 {
-       Paragraph::depth_type const depth = par_.getDepth();
+       Paragraph::depth_type const depth = pit_->getDepth();
 
        if (depth <= 0)
                return;
@@ -610,7 +605,7 @@ int RowPainter::paintAppendixStart(int y)
 
 void RowPainter::paintFirst()
 {
-       ParagraphParameters const & parparams = par_.params();
+       ParagraphParameters const & parparams = pit_->params();
 
        int y_top = 0;
 
@@ -635,18 +630,18 @@ void RowPainter::paintFirst()
 
        Buffer const * buffer = bv_.buffer();
 
-       LyXLayout_ptr const & layout = par_.layout();
+       LyXLayout_ptr const & layout = pit_->layout();
 
        if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
-               if (par_.previous()) {
+               if (pit_->previous()) {
                        if (layout->latextype == LATEX_PARAGRAPH
-                               && !par_.getDepth()) {
+                               && !pit_->getDepth()) {
                                y_top += buffer->params.getDefSkip().inPixels(bv_);
                        } else {
                                LyXLayout_ptr const & playout =
-                                       par_.previous()->layout();
+                                       boost::prior(pit_)->layout();
                                if (playout->latextype == LATEX_PARAGRAPH
-                                       && !par_.previous()->getDepth()) {
+                                       && !boost::prior(pit_)->getDepth()) {
                                        // is it right to use defskip here, too? (AS)
                                        y_top += buffer->params.getDefSkip().inPixels(bv_);
                                }
@@ -672,18 +667,18 @@ void RowPainter::paintFirst()
                y_top += asc;
        }
 
-       bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
+       bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
 
        // should we print a label?
        if (layout->labeltype >= LABEL_STATIC
            && (layout->labeltype != LABEL_STATIC
                || layout->latextype != LATEX_ENVIRONMENT
-               || par_.isFirstInSequence())) {
+               || pit_->isFirstInSequence())) {
 
                LyXFont font = getLabelFont();
-               if (!par_.getLabelstring().empty()) {
+               if (!pit_->getLabelstring().empty()) {
                        float x = x_;
-                       string const str = par_.getLabelstring();
+                       string const str = pit_->getLabelstring();
 
                        // this is special code for the chapter layout. This is
                        // printed in an extra row and has a pagebreak at
@@ -726,13 +721,13 @@ void RowPainter::paintFirst()
 
        // the labels at the top of an environment.
        // More or less for bibliography
-       } else if (par_.isFirstInSequence() &&
+       } else if (pit_->isFirstInSequence() &&
                (layout->labeltype == LABEL_TOP_ENVIRONMENT ||
                layout->labeltype == LABEL_BIBLIO ||
                layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT)) {
                LyXFont font = getLabelFont();
-               if (!par_.getLabelstring().empty()) {
-                       string const str = par_.getLabelstring();
+               if (!pit_->getLabelstring().empty()) {
+                       string const str = pit_->getLabelstring();
                        float spacing_val = 1.0;
                        if (!parparams.spacing().isDefault()) {
                                spacing_val = parparams.spacing().getValue();
@@ -763,7 +758,7 @@ void RowPainter::paintFirst()
 
 void RowPainter::paintLast()
 {
-       ParagraphParameters const & parparams = par_.params();
+       ParagraphParameters const & parparams = pit_->params();
        int y_bottom = row_->height() - 1;
 
        // the bottom margin
@@ -787,7 +782,7 @@ void RowPainter::paintLast()
        if (parparams.lineBottom()) {
                LyXFont font(LyXFont::ALL_SANE);
                int const asc = font_metrics::ascent('x',
-                       getFont(max(pos_type(0), par_.size() - 1)));
+                       getFont(max(pos_type(0), pit_->size() - 1)));
 
                y_bottom -= asc;
 
@@ -800,8 +795,8 @@ void RowPainter::paintLast()
                y_bottom -= asc;
        }
 
-       bool const is_rtl = par_.isRightToLeftPar(bv_.buffer()->params);
-       int const endlabel = par_.getEndLabel();
+       bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params);
+       int const endlabel = pit_->getEndLabel();
 
        // draw an endlabel
        switch (endlabel) {
@@ -831,7 +826,7 @@ void RowPainter::paintLast()
 #else
                LyXFont font = getLabelFont();
 #endif
-               string const & str = par_.layout()->endlabelstring();
+               string const & str = pit_->layout()->endlabelstring();
                int const x = is_rtl ?
                        int(x_) - font_metrics::width(str, font)
                        : ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
@@ -847,14 +842,14 @@ void RowPainter::paintLast()
 void RowPainter::paintText()
 {
        pos_type const last = lastPrintablePos(text_, row_);
-       pos_type body_pos = par_.beginningOfBody();
+       pos_type body_pos = pit_->beginningOfBody();
        if (body_pos > 0 &&
                (body_pos - 1 > last ||
-               !par_.isLineSeparator(body_pos - 1))) {
+               !pit_->isLineSeparator(body_pos - 1))) {
                body_pos = 0;
        }
 
-       LyXLayout_ptr const & layout = par_.layout();
+       LyXLayout_ptr const & layout = pit_->layout();
 
        bool running_strikeout = false;
        bool is_struckout = false;
@@ -866,7 +861,7 @@ void RowPainter::paintText()
                        break;
                pos_type pos = text_.vis2log(vpos);
 
-               if (pos >= par_.size()) {
+               if (pos >= pit_->size()) {
                        ++vpos;
                        continue;
                }
@@ -877,15 +872,15 @@ void RowPainter::paintText()
                        continue;
                }
 
-               is_struckout = isDeletedText(par_, pos);
+               is_struckout = isDeletedText(*pit_, pos);
 
                if (is_struckout && !running_strikeout) {
                        running_strikeout = true;
                        last_strikeout_x = x_;
                }
 
-               bool const highly_editable_inset = par_.isInset(pos)
-                       && isHighlyEditableInset(par_.getInset(pos));
+               bool const highly_editable_inset = pit_->isInset(pos)
+                       && isHighlyEditableInset(pit_->getInset(pos));
 
                // if we reach the end of a struck out range, paint it
                // we also don't paint across things like tables
@@ -905,7 +900,7 @@ void RowPainter::paintText()
                                - singleWidth(body_pos - 1);
                }
 
-               if (par_.isHfill(pos)) {
+               if (pit_->isHfill(pos)) {
                        x_ += 1;
 
                        int const y0 = yo_ + row_->baseline();
@@ -936,7 +931,7 @@ void RowPainter::paintText()
                        }
                        x_ += 2;
                        ++vpos;
-               } else if (par_.isSeparator(pos)) {
+               } else if (pit_->isSeparator(pos)) {
                        x_ += singleWidth(pos);
                        if (pos >= body_pos)
                                x_ += separator_;
index 861580b9361a303d2228010763d14220c8c872e7..868b97c6a170c6fb0b45c646b1d1716a6b7dd449 100644 (file)
@@ -1,4 +1,4 @@
-// -** C++ -*-
+// -*- C++ -*-
 /**
  * \file rowpainter.h
  * This file is part of LyX, the document processor.
@@ -85,7 +85,7 @@ private:
        RowList::iterator row_;
 
        /// Row's paragraph
-       Paragraph const & par_;
+       mutable ParagraphList::iterator  pit_;
 
        // Looks ugly - is
        int xo_;
index df27caa3d352d3dda82abc33afb5cf2d766f1232..98b74ffb01c43d16a02af37910e40cc9b0bea1ac 100644 (file)
@@ -186,8 +186,9 @@ int LyXText::getRealCursorX() const
 }
 
 
-unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
-                       pos_type pos) const
+#warning FIXME  This function seems to belong outside of LyxText.
+unsigned char LyXText::transformChar(unsigned char c, Paragraph const & par,
+                                    pos_type pos) const
 {
        if (!Encodings::is_arabic(c))
                if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && IsDigit(c))
@@ -195,12 +196,12 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
                else
                        return c;
 
-       unsigned char const prev_char = pos > 0 ? par->getChar(pos-1) : ' ';
+       unsigned char const prev_char = pos > 0 ? par.getChar(pos - 1) : ' ';
        unsigned char next_char = ' ';
 
-       for (pos_type i = pos+1; i < par->size(); ++i)
-               if (!Encodings::IsComposeChar_arabic(par->getChar(i))) {
-                       next_char = par->getChar(i);
+       for (pos_type i = pos + 1; i < par.size(); ++i)
+               if (!Encodings::IsComposeChar_arabic(par.getChar(i))) {
+                       next_char = par.getChar(i);
                        break;
                }
 
@@ -244,26 +245,23 @@ unsigned char LyXText::transformChar(unsigned char c, Paragraph * par,
 //
 // Lgb
 
-#warning FIXME Convert this to ParagraphList::iterator
-int LyXText::singleWidth(Paragraph * par,
-                        pos_type pos) const
+int LyXText::singleWidth(ParagraphList::iterator pit, pos_type pos) const
 {
-       if (pos >= par->size())
+       if (pos >= pit->size())
                return 0;
 
-       char const c = par->getChar(pos);
-       return singleWidth(par, pos, c);
+       char const c = pit->getChar(pos);
+       return singleWidth(pit, pos, c);
 }
 
 
-#warning FIXME Convert this to ParagraphList::iterator
-int LyXText::singleWidth(Paragraph * par,
+int LyXText::singleWidth(ParagraphList::iterator pit,
                         pos_type pos, char c) const
 {
-       if (pos >= par->size())
+       if (pos >= pit->size())
                return 0;
 
-       LyXFont const font = getFont(bv()->buffer(), par, pos);
+       LyXFont const font = getFont(bv()->buffer(), pit, pos);
 
        // The most common case is handled first (Asger)
        if (IsPrintable(c)) {
@@ -274,7 +272,7 @@ int LyXText::singleWidth(Paragraph * par,
                                if (Encodings::IsComposeChar_arabic(c))
                                        return 0;
                                else
-                                       c = transformChar(c, par, pos);
+                                       c = transformChar(c, *pit, pos);
                        } else if (font.language()->lang() == "hebrew" &&
                                 Encodings::IsComposeChar_hebrew(c))
                                return 0;
@@ -284,7 +282,7 @@ int LyXText::singleWidth(Paragraph * par,
        }
 
        if (c == Paragraph::META_INSET) {
-               Inset * tmpinset = par->getInset(pos);
+               Inset * tmpinset = pit->getInset(pos);
                if (tmpinset) {
                        if (tmpinset->lyxCode() == Inset::HFILL_CODE) {
                                // Because of the representation as vertical lines
@@ -794,14 +792,14 @@ LyXText::rowBreakPoint(Row const & row) const
 
                char const c = pit->getChar(i);
 
-               int thiswidth = singleWidth(&*pit, i, c);
+               int thiswidth = singleWidth(pit, i, c);
 
                // add the auto-hfill from label end to the body
                if (body_pos && i == body_pos) {
                        thiswidth += font_metrics::width(layout->labelsep,
                                    getLabelFont(bv()->buffer(), &*pit));
                        if (pit->isLineSeparator(i - 1))
-                               thiswidth -= singleWidth(&*pit, i - 1);
+                               thiswidth -= singleWidth(pit, i - 1);
                }
 
                x += thiswidth;
@@ -898,18 +896,18 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
                if (body_pos > 0 && i == body_pos) {
                        w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit));
                        if (pit->isLineSeparator(i - 1))
-                               w -= singleWidth(&*pit, i - 1);
+                               w -= singleWidth(pit, i - 1);
                        int left_margin = labelEnd(*row);
                        if (w < left_margin)
                                w = left_margin;
                }
-               w += singleWidth(&*pit, i);
+               w += singleWidth(pit, i);
                ++i;
        }
        if (body_pos > 0 && body_pos > last) {
                w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit));
                if (last >= 0 && pit->isLineSeparator(last))
-                       w -= singleWidth(&*pit, last);
+                       w -= singleWidth(pit, last);
                int const left_margin = labelEnd(*row);
                if (w < left_margin)
                        w = left_margin;
@@ -938,7 +936,7 @@ int LyXText::labelFill(Row const & row) const
        int w = 0;
        pos_type i = row.pos();
        while (i <= last) {
-               w += singleWidth(&*row.par(), i);
+               w += singleWidth(row.par(), i);
                ++i;
        }
 
@@ -1038,7 +1036,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                                        maxdesc = max(maxdesc, desc);
                                }
                        } else {
-                               maxwidth += singleWidth(&*rit->par(), pos);
+                               maxwidth += singleWidth(rit->par(), pos);
                        }
                }
        }
index 76ff3bfa131b878ef308a4e80caf4e09bc2e49ab..80335014393a33c5b1765fb6642fed8bbc1c6537 100644 (file)
@@ -133,26 +133,26 @@ LyXFont const realizeFont(LyXFont const & font,
 // smaller. (Asger)
 // If position is -1, we get the layout font of the paragraph.
 // If position is -2, we get the font of the manual label of the paragraph.
-LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
+LyXFont const LyXText::getFont(Buffer const * buf, ParagraphList::iterator pit,
                               pos_type pos) const
 {
        lyx::Assert(pos >= 0);
 
-       LyXLayout_ptr const & layout = par->layout();
+       LyXLayout_ptr const & layout = pit->layout();
 
        // We specialize the 95% common case:
-       if (!par->getDepth()) {
+       if (!pit->getDepth()) {
                if (layout->labeltype == LABEL_MANUAL
-                   && pos < par->beginningOfBody()) {
+                   && pos < pit->beginningOfBody()) {
                        // 1% goes here
-                       LyXFont f = par->getFontSettings(buf->params, pos);
-                       if (par->inInset())
-                               par->inInset()->getDrawFont(f);
+                       LyXFont f = pit->getFontSettings(buf->params, pos);
+                       if (pit->inInset())
+                               pit->inInset()->getDrawFont(f);
                        return f.realize(layout->reslabelfont);
                } else {
-                       LyXFont f = par->getFontSettings(buf->params, pos);
-                       if (par->inInset())
-                               par->inInset()->getDrawFont(f);
+                       LyXFont f = pit->getFontSettings(buf->params, pos);
+                       if (pit->inInset())
+                               pit->inInset()->getDrawFont(f);
                        return f.realize(layout->resfont);
                }
        }
@@ -161,7 +161,7 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
 
        LyXFont layoutfont;
 
-       if (pos < par->beginningOfBody()) {
+       if (pos < pit->beginningOfBody()) {
                // 1% goes here
                layoutfont = layout->labelfont;
        } else {
@@ -169,13 +169,13 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
                layoutfont = layout->font;
        }
 
-       LyXFont tmpfont = par->getFontSettings(buf->params, pos);
+       LyXFont tmpfont = pit->getFontSettings(buf->params, pos);
        tmpfont.realize(layoutfont);
 
-       if (par->inInset())
-               par->inInset()->getDrawFont(tmpfont);
+       if (pit->inInset())
+               pit->inInset()->getDrawFont(tmpfont);
 
-       return realizeFont(tmpfont, buf, par);
+       return realizeFont(tmpfont, buf, &*pit);
 }
 
 
@@ -648,7 +648,6 @@ void LyXText::redoParagraphs(LyXCursor const & cur,
                             Paragraph const * ep)
 {
        RowList::iterator tmprit = cur.row();
-       ParagraphList::iterator begpit = cur.row()->par();
        ParagraphList::iterator endpit(const_cast<Paragraph*>(ep));
        int y = cur.y() - tmprit->baseline();
 
@@ -1771,21 +1770,21 @@ float LyXText::getCursorX(RowList::iterator rit,
                                        getLabelFont(bv()->buffer(),
                                                     &*rit->par()));
                        if (rit->par()->isLineSeparator(body_pos - 1))
-                               x -= singleWidth(&*rit->par(), body_pos - 1);
+                               x -= singleWidth(rit->par(), body_pos - 1);
                }
 
                if (hfillExpansion(*this, rit, pos)) {
-                       x += singleWidth(&*rit->par(), pos);
+                       x += singleWidth(rit->par(), pos);
                        if (pos >= body_pos)
                                x += fill_hfill;
                        else
                                x += fill_label_hfill;
                } else if (rit->par()->isSeparator(pos)) {
-                       x += singleWidth(&*rit->par(), pos);
+                       x += singleWidth(rit->par(), pos);
                        if (pos >= body_pos)
                                x += fill_separator;
                } else
-                       x += singleWidth(&*rit->par(), pos);
+                       x += singleWidth(rit->par(), pos);
        }
        return x;
 }
@@ -1906,21 +1905,21 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
                                font_metrics::width(layout->labelsep,
                                               getLabelFont(bv()->buffer(), &*rit->par()));
                        if (rit->par()->isLineSeparator(body_pos - 1))
-                               tmpx -= singleWidth(&*rit->par(), body_pos - 1);
+                               tmpx -= singleWidth(rit->par(), body_pos - 1);
                }
 
                if (hfillExpansion(*this, rit, c)) {
-                       tmpx += singleWidth(&*rit->par(), c);
+                       tmpx += singleWidth(rit->par(), c);
                        if (c >= body_pos)
                                tmpx += fill_hfill;
                        else
                                tmpx += fill_label_hfill;
                } else if (rit->par()->isSeparator(c)) {
-                       tmpx += singleWidth(&*rit->par(), c);
+                       tmpx += singleWidth(rit->par(), c);
                        if (c >= body_pos)
                                tmpx+= fill_separator;
                } else {
-                       tmpx += singleWidth(&*rit->par(), c);
+                       tmpx += singleWidth(rit->par(), c);
                }
                ++vc;
        }
@@ -1964,9 +1963,9 @@ LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
        if (rit->pos() <= last && c > last
            && rit->par()->isNewline(last)) {
                if (bidi_level(last) % 2 == 0)
-                       tmpx -= singleWidth(&*rit->par(), last);
+                       tmpx -= singleWidth(rit->par(), last);
                else
-                       tmpx += singleWidth(&*rit->par(), last);
+                       tmpx += singleWidth(rit->par(), last);
                c = last;
        }