]> git.lyx.org Git - lyx.git/blobdiff - src/Text2.cpp
This doesn't return a reference any more.
[lyx.git] / src / Text2.cpp
index 26b62f72f677e83caa3783886b83e9bfcc7e4421..27fe087c109159ca389500175e9b16980c65c9ed 100644 (file)
@@ -50,6 +50,7 @@
 
 #include "mathed/InsetMathHull.h"
 
+#include "support/assert.h"
 #include "support/debug.h"
 #include "support/gettext.h"
 #include "support/textutils.h"
@@ -75,17 +76,17 @@ bool Text::isMainText(Buffer const & buffer) const
 
 FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
 {
-       LayoutPtr const & layout = pars_[pit].layout();
+       Layout const & layout = pars_[pit].layout();
 
        if (!pars_[pit].getDepth())  {
-               FontInfo lf = layout->resfont;
+               FontInfo lf = layout.resfont;
                // In case the default family has been customized
-               if (layout->font.family() == INHERIT_FAMILY)
+               if (layout.font.family() == INHERIT_FAMILY)
                        lf.setFamily(buffer.params().getFont().fontInfo().family());
                return lf;
        }
 
-       FontInfo font = layout->font;
+       FontInfo font = layout.font;
        // Realize with the fonts of lesser depth.
        //font.realize(outerFont(pit, paragraphs()));
        font.realize(buffer.params().getFont().fontInfo());
@@ -96,17 +97,17 @@ FontInfo Text::layoutFont(Buffer const & buffer, pit_type const pit) const
 
 FontInfo Text::labelFont(Buffer const & buffer, Paragraph const & par) const
 {
-       LayoutPtr const & layout = par.layout();
+       Layout const & layout = par.layout();
 
        if (!par.getDepth()) {
-               FontInfo lf = layout->reslabelfont;
+               FontInfo lf = layout.reslabelfont;
                // In case the default family has been customized
-               if (layout->labelfont.family() == INHERIT_FAMILY)
+               if (layout.labelfont.family() == INHERIT_FAMILY)
                        lf.setFamily(buffer.params().getFont().fontInfo().family());
                return lf;
        }
 
-       FontInfo font = layout->labelfont;
+       FontInfo font = layout.labelfont;
        // Realize with the fonts of lesser depth.
        font.realize(buffer.params().getFont().fontInfo());
 
@@ -118,15 +119,15 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
                pos_type pos, Font const & fnt, Font const & display_font)
 {
        Font font = fnt;
-       LayoutPtr const & layout = pars_[pit].layout();
+       Layout const & layout = pars_[pit].layout();
 
        // Get concrete layout font to reduce against
        FontInfo layoutfont;
 
        if (pos < pars_[pit].beginOfBody())
-               layoutfont = layout->labelfont;
+               layoutfont = layout.labelfont;
        else
-               layoutfont = layout->font;
+               layoutfont = layout.font;
 
        // Realize against environment font information
        if (pars_[pit].getDepth()) {
@@ -136,7 +137,7 @@ void Text::setCharFont(Buffer const & buffer, pit_type pit,
                       pars_[tp].getDepth()) {
                        tp = outerHook(tp, paragraphs());
                        if (tp != pit_type(paragraphs().size()))
-                               layoutfont.realize(pars_[tp].layout()->font);
+                               layoutfont.realize(pars_[tp].layout().font);
                }
        }
 
@@ -158,7 +159,7 @@ void Text::setInsetFont(BufferView const & bv, pit_type pit,
                pos_type pos, Font const & font, bool toggleall)
 {
        Inset * const inset = pars_[pit].getInset(pos);
-       BOOST_ASSERT(inset && inset->noFontChange());
+       LASSERT(inset && inset->noFontChange(), /**/);
 
        CursorSlice::idx_type endidx = inset->nargs();
        for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
@@ -196,7 +197,7 @@ pit_type Text::undoSpan(pit_type pit)
 void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
                docstring const & layout)
 {
-       BOOST_ASSERT(start != end);
+       LASSERT(start != end, /**/);
 
        BufferParams const & bufparams = buffer.params();
        Layout const & lyxlayout = bufparams.documentClass()[layout];
@@ -214,7 +215,7 @@ void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
 // set layout over selection and make a total rebreak of those paragraphs
 void Text::setLayout(Cursor & cur, docstring const & layout)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        // special handling of new environment insets
        BufferView & bv = cur.bv();
        BufferParams const & params = bv.buffer().params();
@@ -244,7 +245,7 @@ void Text::setLayout(Cursor & cur, docstring const & layout)
 static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
                        Paragraph const & par, int max_depth)
 {
-       if (par.layout()->labeltype == LABEL_BIBLIO)
+       if (par.layout().labeltype == LABEL_BIBLIO)
                return false;
        int const depth = par.params().depth();
        if (type == Text::INC_DEPTH && depth < max_depth)
@@ -257,7 +258,7 @@ static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
 
 bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        // this happens when selecting several cells in tabular (bug 2630)
        if (cur.selBegin().idx() != cur.selEnd().idx())
                return false;
@@ -277,7 +278,7 @@ bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
 
 void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        pit_type const beg = cur.selBegin().pit();
        pit_type const end = cur.selEnd().pit() + 1;
        cur.recordUndoSelection();
@@ -302,7 +303,7 @@ void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
 
 void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        // Set the current_font
        // Determine basis font
        FontInfo layoutfont;
@@ -369,21 +370,21 @@ void Text::setFont(BufferView const & bv, CursorSlice const & begin,
 
 bool Text::cursorTop(Cursor & cur)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        return setCursor(cur, 0, 0);
 }
 
 
 bool Text::cursorBottom(Cursor & cur)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
 }
 
 
 void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        // If the mask is completely neutral, tell user
        if (font.fontInfo() == ignore_font && 
                (font.language() == 0 || font.language() == ignore_language)) {
@@ -416,7 +417,7 @@ void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
 
 docstring Text::getStringToIndex(Cursor const & cur)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
 
        if (cur.selection())
                return cur.selectionAsString(false);
@@ -440,7 +441,7 @@ docstring Text::getStringToIndex(Cursor const & cur)
 
 void Text::setParagraphs(Cursor & cur, docstring arg, bool merge) 
 {
-       BOOST_ASSERT(cur.text());
+       LASSERT(cur.text(), /**/);
        // make sure that the depth behind the selection are restored, too
        pit_type undopit = undoSpan(cur.selEnd().pit());
        recUndo(cur, cur.selBegin().pit(), undopit - 1);
@@ -452,7 +453,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
                Paragraph & par = pars_[pit];
                ParagraphParameters params = par.params();
                params.read(argument, merge);
-               par.params().apply(params, *par.layout());
+               par.params().apply(params, par.layout());
        }
 }
 
@@ -462,7 +463,7 @@ void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
 //quite so much.
 void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p) 
 {
-       BOOST_ASSERT(cur.text());
+       LASSERT(cur.text(), /**/);
        // make sure that the depth behind the selection are restored, too
        pit_type undopit = undoSpan(cur.selEnd().pit());
        recUndo(cur, cur.selBegin().pit(), undopit - 1);
@@ -470,8 +471,7 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
        for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
             pit <= end; ++pit) {
                Paragraph & par = pars_[pit];
-               Layout const & layout = *(par.layout());
-               par.params().apply(p, layout);
+               par.params().apply(p, par.layout());
        }       
 }
 
@@ -479,8 +479,8 @@ void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
 // this really should just insert the inset and not move the cursor.
 void Text::insertInset(Cursor & cur, Inset * inset)
 {
-       BOOST_ASSERT(this == cur.text());
-       BOOST_ASSERT(inset);
+       LASSERT(this == cur.text(), /**/);
+       LASSERT(inset, /**/);
        cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
                Change(cur.buffer().params().trackChanges
                ? Change::INSERTED : Change::UNCHANGED));
@@ -535,7 +535,7 @@ bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos,
 
 void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
 {
-       BOOST_ASSERT(par != int(paragraphs().size()));
+       LASSERT(par != int(paragraphs().size()), /**/);
        cur.pit() = par;
        cur.pos() = pos;
 
@@ -545,14 +545,14 @@ 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;
-               BOOST_ASSERT(false);
+               LASSERT(false, /**/);
        }
 
        if (pos > para.size()) {
                lyxerr << "dont like 1, pos: " << pos
                       << " size: " << para.size()
                       << " par: " << par << endl;
-               BOOST_ASSERT(false);
+               LASSERT(false, /**/);
        }
 }
 
@@ -560,7 +560,7 @@ void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
 void Text::setCursorIntern(Cursor & cur,
                              pit_type par, pos_type pos, bool setfont, bool boundary)
 {
-       BOOST_ASSERT(this == cur.text());
+       LASSERT(this == cur.text(), /**/);
        cur.boundary(boundary);
        setCursor(cur.top(), par, pos);
        if (setfont)
@@ -678,7 +678,7 @@ bool Text::cursorVisLeft(Cursor & cur, bool skip_inset)
        }
 
        // Are we already at leftmost pos in row?
-       if (left_pos == -1) {
+       if (cur.text()->empty() || left_pos == -1) {
                
                Cursor new_cur = cur;
                if (!new_cur.posVisToNewRow(true)) {
@@ -768,7 +768,7 @@ bool Text::cursorVisRight(Cursor & cur, bool skip_inset)
        }
 
        // Are we already at rightmost pos in row?
-       if (right_pos == -1) {
+       if (cur.text()->empty() || right_pos == -1) {
                
                Cursor new_cur = cur;
                if (!new_cur.posVisToNewRow(false)) {
@@ -1041,7 +1041,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
 void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges)
 {
-       BOOST_ASSERT(first >= 0 && first <= last && last < (int) pars_.size());
+       LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), /**/);
 
        for (pit_type pit = first; pit <= last; ++pit) {
                Paragraph & par = pars_[pit];