]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
Look for mathed xpms. Doesn't do anything yet due to lack of workable XPMs
[lyx.git] / src / text2.C
index afd3351592f05201454b1ae4d038d09c060a41b3..984a3f4cad759ef3edfd5bac568430c76f0a5230 100644 (file)
@@ -163,9 +163,8 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
 
        LyXLayout_ptr const & layout = par->layout();
 
-       Paragraph::depth_type par_depth = par->getDepth();
        // We specialize the 95% common case:
-       if (!par_depth) {
+       if (!par->getDepth()) {
                if (layout->labeltype == LABEL_MANUAL
                    && pos < beginningOfMainBody(buf, par)) {
                        // 1% goes here
@@ -218,9 +217,7 @@ LyXFont const LyXText::getLayoutFont(Buffer const * buf, Paragraph * par) const
 {
        LyXLayout_ptr const & layout = par->layout();
 
-       Paragraph::depth_type par_depth = par->getDepth();
-
-       if (!par_depth) {
+       if (!par->getDepth()) {
                return layout->resfont;
        }
 
@@ -232,9 +229,7 @@ LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const
 {
        LyXLayout_ptr const & layout = par->layout();
 
-       Paragraph::depth_type par_depth = par->getDepth();
-
-       if (!par_depth) {
+       if (!par->getDepth()) {
                return layout->reslabelfont;
        }
 
@@ -387,10 +382,11 @@ void LyXText::removeParagraph(Row * row) const
 void LyXText::insertParagraph(BufferView * bview, Paragraph * par,
                              Row * row) const
 {
-       insertRow(row, par, 0);            /* insert a new row, starting
-                                           * at position 0 */
+       // insert a new row, starting at position 0
+       insertRow(row, par, 0);
 
-       setCounter(bview->buffer(), par);  // set the counters
+       // set the counters
+       setCounter(bview->buffer(), par);
 
        // and now append the whole paragraph behind the new row
        if (!row) {
@@ -1269,13 +1265,13 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
        }
 
        // is it a layout that has an automatic label?
-       if (layout->labeltype >=  LABEL_COUNTER_CHAPTER) {
+       if (layout->labeltype >= LABEL_COUNTER_CHAPTER) {
 
                int i = layout->labeltype - LABEL_COUNTER_CHAPTER;
                string numbertype, langtype;
                ostringstream s;
 
-               if (i >= 0 && i<= buf->params.secnumdepth) {
+               if (i >= 0 && i <= buf->params.secnumdepth) {
 
                        buf->counters().step(buf->counters().sects[i]);
 
@@ -1339,33 +1335,43 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
 
                // the caption hack:
                if (layout->labeltype == LABEL_SENSITIVE) {
-                       bool isOK (par->inInset() && par->inInset()->owner() &&
-                                  (par->inInset()->owner()->lyxCode() == Inset::FLOAT_CODE));
+                       Paragraph * tmppar = par;
+                       Inset * in = 0;
+                       bool isOK = false;
+                       while (tmppar && tmppar->inInset()
+                              // the single '=' is intended below
+                              && (in = tmppar->inInset()->owner())) {
+                               if (in->lyxCode() == Inset::FLOAT_CODE) {
+                                       isOK = true;
+                                       break;
+                               } else {
+                                       tmppar = in->parOwner();
+                               }
+                       }
 
                        if (isOK) {
-                               InsetFloat * tmp = static_cast<InsetFloat*>(par->inInset()->owner());
                                Floating const & fl
-                                       = floatList.getType(tmp->type());
+                                       = textclass.floats().getType(static_cast<InsetFloat*>(in)->type());
 
                                buf->counters().step(fl.name());
-                               
+
                                // Doesn't work... yet.
                                ostringstream o;
                                //o << fl.name() << " " << buf->counters().value(fl.name()) << ":";
                                o << fl.name() << " #:";
                                s = o.str();
                        } else {
-                               /* par->SetLayout(0);
-                                  s = layout->labelstring;  */
+                               // par->SetLayout(0);
+                               // s = layout->labelstring;
                                s = (par->getParLanguage(buf->params)->lang() == "hebrew")
                                        ? " :úåòîùî øñç" : "Senseless: ";
                        }
                }
                par->params().labelString(s);
 
-               /* reset the enumeration counter. They are always resetted
-                * when there is any other layout between */
-               for (int i = par->enumdepth + 1; i < 4; i++) {
+               // reset the enumeration counter. They are always resetted
+               // when there is any other layout between
+               for (int i = par->enumdepth; i < 4; ++i) {
                        buf->counters().set(buf->counters().enums[i], 0);
                }
        }
@@ -1377,7 +1383,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
 void LyXText::updateCounters(BufferView * bview) const
 {
        Paragraph * par;
-       
+
        Row * row = firstrow;
        par = row->par();
 
@@ -1385,7 +1391,7 @@ void LyXText::updateCounters(BufferView * bview) const
        while (par) {
                while (row->par() != par)
                        row = row->next();
-               
+
                setCounter(bview->buffer(), par);
 
                // now check for the headline layouts. remember that they
@@ -1661,37 +1667,6 @@ void LyXText::insertStringAsParagraphs(BufferView * bview, string const & str)
 }
 
 
-bool LyXText::gotoNextInset(BufferView * bview,
-                           vector<Inset::Code> const & codes,
-                           string const & contents) const
-{
-       LyXCursor res = cursor;
-       Inset * inset;
-       do {
-               if (res.pos() < res.par()->size() - 1) {
-                       res.pos(res.pos() + 1);
-               } else  {
-                       res.par(res.par()->next());
-                       res.pos(0);
-               }
-
-       } while (res.par() &&
-                !(res.par()->isInset(res.pos())
-                  && (inset = res.par()->getInset(res.pos())) != 0
-                  && find(codes.begin(), codes.end(), inset->lyxCode())
-                  != codes.end()
-                  && (contents.empty() ||
-                      static_cast<InsetCommand *>(res.par()->getInset(res.pos()))->getContents()
-                      == contents)));
-
-       if (res.par()) {
-               setCursor(bview, res.par(), res.pos(), false);
-               return true;
-       }
-       return false;
-}
-
-
 void LyXText::checkParagraph(BufferView * bview, Paragraph * par,
                             pos_type pos)
 {
@@ -2103,8 +2078,7 @@ void LyXText::cursorUp(BufferView * bview, bool selecting) const
                int y1 = cursor.iy() - first_y;
                int y2 = y1;
                y -= first_y;
-               Inset * inset_hit =
-                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               Inset * inset_hit = checkInsetHit(bview, x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit)) {
                        inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
                }
@@ -2127,8 +2101,7 @@ void LyXText::cursorDown(BufferView * bview, bool selecting) const
                int y1 = cursor.iy() - first_y;
                int y2 = y1;
                y -= first_y;
-               Inset * inset_hit =
-                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               Inset * inset_hit = checkInsetHit(bview, x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit)) {
                        inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
                }