]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
After a hiatus, I'm returning to the rewrite of InsetCommandParams, the purpose of...
[lyx.git] / src / Text3.cpp
index b8e3ce0a200f54b4d061ed9a046c54c0bda2d016..4be361630a60dbdd76c6cc61483c13cc990fdbdb 100644 (file)
@@ -219,10 +219,8 @@ static bool doInsertInset(Cursor & cur, Text * text,
        InsetText * insetText = dynamic_cast<InsetText *>(inset);
        if (insetText && !insetText->allowMultiPar() || cur.lastpit() == 0) {
                // reset first par to default
-               LayoutPtr const layout = insetText->useEmptyLayout()
-                       ? bparams.getTextClass().emptyLayout()
-                       : bparams.getTextClass().defaultLayout();
-               cur.text()->paragraphs().begin()->layout(layout);
+               cur.text()->paragraphs().begin()
+                       ->setEmptyOrDefaultLayout(bparams.textClass());
                cur.pos() = 0;
                cur.pit() = 0;
                // Merge multiple paragraphs -- hack
@@ -231,8 +229,8 @@ static bool doInsertInset(Cursor & cur, Text * text,
        } else {
                // reset surrounding par to default
                docstring const layoutname = insetText->useEmptyLayout()
-                       ? bparams.getTextClass().emptyLayoutName()
-                       : bparams.getTextClass().defaultLayoutName();
+                       ? bparams.textClass().emptyLayoutName()
+                       : bparams.textClass().defaultLayoutName();
                cur.leaveInset(*inset);
                text->setLayout(cur, layoutname);
        }
@@ -268,10 +266,7 @@ static void outline(OutlineOp mode, Cursor & cur)
        ParagraphList::iterator finish = start;
        ParagraphList::iterator end = pars.end();
 
-       TextClass::const_iterator lit =
-               buf.params().getTextClass().begin();
-       TextClass::const_iterator const lend =
-               buf.params().getTextClass().end();
+       TextClass const & tc = buf.params().textClass();
 
        int const thistoclevel = start->layout()->toclevel;
        int toclevel;
@@ -346,20 +341,22 @@ static void outline(OutlineOp mode, Cursor & cur)
                }
                case OutlineIn:
                        buf.undo().recordUndo(cur);
-                       for (; lit != lend; ++lit) {
-                               if ((*lit)->toclevel == thistoclevel + 1 &&
-                                   start->layout()->labeltype == (*lit)->labeltype) {
-                                       start->layout((*lit));
+                       for (size_t i = 0; i != tc.layoutCount(); ++i) {
+                               LayoutPtr const & lt = tc.layout(i);
+                               if (lt->toclevel == thistoclevel + 1 &&
+                                   start->layout()->labeltype == lt->labeltype) {
+                                       start->setLayout(lt);
                                        break;
                                }
                        }
                        break;
                case OutlineOut:
                        buf.undo().recordUndo(cur);
-                       for (; lit != lend; ++lit) {
-                               if ((*lit)->toclevel == thistoclevel - 1 &&
-                                   start->layout()->labeltype == (*lit)->labeltype) {
-                                       start->layout((*lit));
+                       for (size_t i = 0; i != tc.layoutCount(); ++i) {
+                               LayoutPtr const & lt = tc.layout(i);
+                               if (lt->toclevel == thistoclevel - 1 &&
+                                   start->layout()->labeltype == lt->labeltype) {
+                                       start->setLayout(lt);
                                        break;
                                }
                        }
@@ -1014,7 +1011,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
                Paragraph const & para = cur.paragraph();
                docstring const old_layout = para.layout()->name();
-               TextClass const & tclass = bv->buffer().params().getTextClass();
+               TextClass const & tclass = bv->buffer().params().textClass();
 
                if (layout.empty())
                        layout = tclass.defaultLayoutName();
@@ -1387,16 +1384,12 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cur.posForward();
                ParagraphList & pars = cur.text()->paragraphs();
 
-               TextClass const & tclass = bv->buffer().params().getTextClass();
+               TextClass const & tclass = bv->buffer().params().textClass();
 
                // add a separate paragraph for the caption inset
                pars.push_back(Paragraph());
                pars.back().setInsetOwner(pars[0].inInset());
-               if (pars.back().useEmptyLayout())
-                       pars.back().layout(tclass.emptyLayout());
-               else
-                       pars.back().layout(tclass.defaultLayout());
-
+               pars.back().setEmptyOrDefaultLayout(tclass);
                int cap_pit = pars.size() - 1;
 
                // if an empty inset was created, we create an additional empty
@@ -1405,10 +1398,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (!content) {
                        pars.push_back(Paragraph());
                        pars.back().setInsetOwner(pars[0].inInset());
-                       if (pars.back().useEmptyLayout())
-                               pars.back().layout(tclass.emptyLayout());
-                       else
-                               pars.back().layout(tclass.defaultLayout());
+                       pars.back().setEmptyOrDefaultLayout(tclass);
                }
 
                // reposition the cursor to the caption
@@ -1685,7 +1675,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
 
        case LFUN_FLOAT_LIST: {
-               TextClass const & tclass = bv->buffer().params().getTextClass();
+               TextClass const & tclass = bv->buffer().params().textClass();
                if (tclass.floats().typeExist(to_utf8(cmd.argument()))) {
                        cur.recordUndo();
                        if (cur.selection())
@@ -1956,7 +1946,7 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_FLEX_INSERT: {
                code = FLEX_CODE;
                string s = cmd.getArg(0);
-               InsetLayout il =  cur.buffer().params().getTextClass().insetlayout(from_utf8(s));
+               InsetLayout il =  cur.buffer().params().textClass().insetLayout(from_utf8(s));
                if (il.lyxtype() != "charstyle" &&
                    il.lyxtype() != "custom" &&
                    il.lyxtype() != "element" &&