]> git.lyx.org Git - features.git/commitdiff
More ParagraphList::iterator work.
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 10 Apr 2003 12:10:04 +0000 (12:10 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 10 Apr 2003 12:10:04 +0000 (12:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6763 a592a061-630c-0410-9148-cb99ea01b6c8

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

index d73285477c3bfc6cff8c5ee4e4e7e49cc23b3d71..e505b288bbc054f93cb94b4d65d87131e053d49e 100644 (file)
@@ -1,3 +1,13 @@
+2003-04-10  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * text2.C: adjust several funcs.
+       (realizeFont): take a ParagraphList::iterator as arg.
+       (getLayoutFont): ditto
+       (getLabelFont): ditto
+       (setCharFont): ditto
+
+       * text.C: adjust several funcs.
+
 2003-04-09  Alfredo Braunstein  <abraunst@libero.it>
 
        * text.C (selectNextWordToSpellcheck): don't accidentally
@@ -10,7 +20,7 @@
 
 2003-04-09  Alfredo Braunstein  <abraunst@libero.it>
 
-       * text2.C (cursorRight): a getChar assert fixed 
+       * text2.C (cursorRight): a getChar assert fixed
 
 2003-04-09  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
index 5cf8229de0a3e98f245a7be5817021a359a507eb..6dd09b6237466e047141c816acf3f5224e928726 100644 (file)
@@ -105,14 +105,17 @@ public:
        LyXFont const getFont(Buffer const *, ParagraphList::iterator pit,
                lyx::pos_type pos) const;
        ///
-       LyXFont const getLayoutFont(Buffer const *, Paragraph * par) const;
+       LyXFont const getLayoutFont(Buffer const *,
+                                   ParagraphList::iterator pit) const;
        ///
-       LyXFont const getLabelFont(Buffer const *, Paragraph * par) const;
+       LyXFont const getLabelFont(Buffer const *,
+                                  ParagraphList::iterator pit) const;
        ///
-       void setCharFont(Buffer const *, Paragraph * par,
+       void setCharFont(Buffer const *, ParagraphList::iterator pit,
                         lyx::pos_type pos, LyXFont const & font);
-       void setCharFont(Paragraph * par,
-                        lyx::pos_type pos, LyXFont const & font, bool toggleall);
+       void setCharFont(ParagraphList::iterator pit,
+                        lyx::pos_type pos,
+                        LyXFont const & font, bool toggleall);
 
        ///
        void breakAgainOneRow(RowList::iterator rit);
index 24e3c11d026335781d4f11d534345221b7a9dc12..a85c76515c4ce8d87349da2d2394fab1d892bab9 100644 (file)
@@ -561,7 +561,7 @@ int LyXText::leftMargin(Row const & row) const
                }
        }
 
-       LyXFont const labelfont = getLabelFont(bv()->buffer(), &*row.par());
+       LyXFont const labelfont = getLabelFont(bv()->buffer(), row.par());
        switch (layout->margintype) {
        case MARGIN_DYNAMIC:
                if (!layout->leftmargin.empty()) {
@@ -797,7 +797,7 @@ LyXText::rowBreakPoint(Row const & row) const
                // 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));
+                                   getLabelFont(bv()->buffer(), pit));
                        if (pit->isLineSeparator(i - 1))
                                thiswidth -= singleWidth(pit, i - 1);
                }
@@ -894,7 +894,7 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
 
        while (i <= last) {
                if (body_pos > 0 && i == body_pos) {
-                       w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit));
+                       w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit));
                        if (pit->isLineSeparator(i - 1))
                                w -= singleWidth(pit, i - 1);
                        int left_margin = labelEnd(*row);
@@ -905,7 +905,7 @@ int LyXText::fill(RowList::iterator row, int paper_width) const
                ++i;
        }
        if (body_pos > 0 && body_pos > last) {
-               w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), &*pit));
+               w += font_metrics::width(layout->labelsep, getLabelFont(bv()->buffer(), pit));
                if (last >= 0 && pit->isLineSeparator(last))
                        w -= singleWidth(pit, last);
                int const left_margin = labelEnd(*row);
@@ -943,7 +943,7 @@ int LyXText::labelFill(Row const & row) const
        int fill = 0;
        string const & labwidstr = row.par()->params().labelWidthString();
        if (!labwidstr.empty()) {
-               LyXFont const labfont = getLabelFont(bv()->buffer(), &*row.par());
+               LyXFont const labfont = getLabelFont(bv()->buffer(), row.par());
                int const labwidth = font_metrics::width(labwidstr, labfont);
                fill = max(labwidth - w, 0);
        }
@@ -991,13 +991,13 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
        // as max get the first character of this row then it can increase but not
        // decrease the height. Just some point to start with so we don't have to
        // do the assignment below too often.
-       LyXFont font = getFont(bv()->buffer(), &*pit, rit->pos());
+       LyXFont font = getFont(bv()->buffer(), pit, rit->pos());
        LyXFont::FONT_SIZE const tmpsize = font.size();
-       font = getLayoutFont(bv()->buffer(), &*pit);
+       font = getLayoutFont(bv()->buffer(), pit);
        LyXFont::FONT_SIZE const size = font.size();
        font.setSize(tmpsize);
 
-       LyXFont labelfont = getLabelFont(bv()->buffer(), &*pit);
+       LyXFont labelfont = getLabelFont(bv()->buffer(), pit);
 
        float spacing_val = 1.0;
        if (!rit->par()->params().spacing().isDefault()) {
@@ -1022,7 +1022,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                // Check if any insets are larger
                for (pos_type pos = rit->pos(); pos <= pos_end; ++pos) {
                        if (rit->par()->isInset(pos)) {
-                               tmpfont = getFont(bv()->buffer(), &*rit->par(), pos);
+                               tmpfont = getFont(bv()->buffer(), rit->par(), pos);
                                tmpinset = rit->par()->getInset(pos);
                                if (tmpinset) {
 #if 1 // this is needed for deep update on initialitation
@@ -1096,7 +1096,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                if (firstpit->params().lineTop())
 
                        maxasc += 2 * font_metrics::ascent('x', getFont(bv()->buffer(),
-                                       &*firstpit, 0));
+                                       firstpit, 0));
                // and now the pagebreaks
                if (firstpit->params().pagebreakTop())
                        maxasc += 3 * defaultRowHeight();
@@ -1210,7 +1210,7 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
                if (firstpit->params().lineBottom())
                        maxdesc += 2 * font_metrics::ascent('x',
                                                       getFont(bv()->buffer(),
-                                                              &*pit,
+                                                              pit,
                                                               max(pos_type(0), pit->size() - 1)));
 
                // and now the pagebreaks
@@ -1548,10 +1548,10 @@ void LyXText::insertChar(char c)
                              cursor.pos() >= 1 &&
                              cursor.pos() < cursor.par()->size() &&
                              getFont(bv()->buffer(),
-                                     &*cursor.par(),
+                                     cursor.par(),
                                      cursor.pos()).number() == LyXFont::ON &&
                              getFont(bv()->buffer(),
-                                     &*cursor.par(),
+                                     cursor.par(),
                                      cursor.pos() - 1).number() == LyXFont::ON)
                           )
                                number(bv()); // Set current_font.number to OFF
@@ -1573,10 +1573,10 @@ void LyXText::insertChar(char c)
                                } else if (contains(number_seperators, c) &&
                                           cursor.pos() >= 2 &&
                                           getFont(bv()->buffer(),
-                                                  &*cursor.par(),
+                                                  cursor.par(),
                                                   cursor.pos() - 2).number() == LyXFont::ON) {
                                        setCharFont(bv()->buffer(),
-                                                   &*cursor.par(),
+                                                   cursor.par(),
                                                    cursor.pos() - 1,
                                                    current_font);
                                }
@@ -1906,7 +1906,7 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x,
                     !rit->par()->isLineSeparator(body_pos - 1))) {
                        x += font_metrics::width(layout->labelsep,
                                            getLabelFont(bv()->buffer(),
-                                                        &*rit->par()));
+                                                        rit->par()));
                        if (body_pos - 1 <= last)
                                x += fill_label_hfill;
                }
@@ -2161,11 +2161,11 @@ LyXText::selectNextWordToSpellcheck(float & value)
 
                bool const is_good_inset = cpit->isInset(cpos)
                        && cpit->getInset(cpos)->allowSpellcheck();
-  
-               if (!isDeletedText(*cpit, cpos) 
+
+               if (!isDeletedText(*cpit, cpos)
                    && (is_good_inset || cpit->isLetter(cpos)))
-                       break;
-  
+                       break;
+
                cursor.pos(cpos + 1);
        }
 
@@ -2189,7 +2189,7 @@ LyXText::selectNextWordToSpellcheck(float & value)
        selection.cursor = cursor;
 
        string lang_code(
-               getFont(bv()->buffer(), &*cursor.par(), cursor.pos())
+               getFont(bv()->buffer(), cursor.par(), cursor.pos())
                        .language()->code());
        // and find the end of the word (insets like optional hyphens
        // and ligature break are part of a word)
index 2ba74b766086cc9dd895bc4750cfbf094c4a646d..764fc073dc7aec7806ad26e40055ae4b631825fe 100644 (file)
@@ -84,15 +84,15 @@ void LyXText::init(BufferView * bview, bool reinit)
        } else if (!rowlist_.empty())
                return;
 
-       ParagraphList::iterator par = ownerParagraphs().begin();
+       ParagraphList::iterator pit = ownerParagraphs().begin();
        ParagraphList::iterator end = ownerParagraphs().end();
 
-       current_font = getFont(bview->buffer(), &*par, 0);
+       current_font = getFont(bview->buffer(), pit, 0);
 
-       for (; par != end; ++par) {
-               insertParagraph(&*par, rowlist_.end());
+       for (; pit != end; ++pit) {
+               insertParagraph(&*pit, rowlist_.end());
        }
-       setCursorIntern(&*rowlist_.begin()->par(), 0);
+       setCursorIntern(rowlist_.begin()->par(), 0);
        selection.cursor = cursor;
 
        updateCounters();
@@ -103,11 +103,14 @@ namespace {
 
 LyXFont const realizeFont(LyXFont const & font,
                          Buffer const * buf,
-                         Paragraph * par)
+                         ParagraphList & /*plist*/,
+                         ParagraphList::iterator pit)
 {
        LyXTextClass const & tclass = buf->params.getLyXTextClass();
        LyXFont tmpfont(font);
-       Paragraph::depth_type par_depth = par->getDepth();
+       Paragraph::depth_type par_depth = pit->getDepth();
+
+       Paragraph * par = &*pit;
 
        // Resolve against environment font information
        while (par && par_depth && !tmpfont.resolved()) {
@@ -175,44 +178,46 @@ LyXFont const LyXText::getFont(Buffer const * buf, ParagraphList::iterator pit,
        if (pit->inInset())
                pit->inInset()->getDrawFont(tmpfont);
 
-       return realizeFont(tmpfont, buf, &*pit);
+       return realizeFont(tmpfont, buf, ownerParagraphs(), pit);
 }
 
 
-LyXFont const LyXText::getLayoutFont(Buffer const * buf, Paragraph * par) const
+LyXFont const LyXText::getLayoutFont(Buffer const * buf,
+                                    ParagraphList::iterator pit) const
 {
-       LyXLayout_ptr const & layout = par->layout();
+       LyXLayout_ptr const & layout = pit->layout();
 
-       if (!par->getDepth()) {
+       if (!pit->getDepth()) {
                return layout->resfont;
        }
 
-       return realizeFont(layout->font, buf, par);
+       return realizeFont(layout->font, buf, ownerParagraphs(), pit);
 }
 
 
-LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const
+LyXFont const LyXText::getLabelFont(Buffer const * buf,
+                                   ParagraphList::iterator pit) const
 {
-       LyXLayout_ptr const & layout = par->layout();
+       LyXLayout_ptr const & layout = pit->layout();
 
-       if (!par->getDepth()) {
+       if (!pit->getDepth()) {
                return layout->reslabelfont;
        }
 
-       return realizeFont(layout->labelfont, buf, par);
+       return realizeFont(layout->labelfont, buf, ownerParagraphs(), pit);
 }
 
 
-void LyXText::setCharFont(Paragraph * par,
+void LyXText::setCharFont(ParagraphList::iterator pit,
                          pos_type pos, LyXFont const & fnt,
                          bool toggleall)
 {
        Buffer const * buf = bv()->buffer();
-       LyXFont font = getFont(buf, par, pos);
+       LyXFont font = getFont(buf, pit, pos);
        font.update(fnt, buf->params.language, toggleall);
        // Let the insets convert their font
-       if (par->isInset(pos)) {
-               Inset * inset = par->getInset(pos);
+       if (pit->isInset(pos)) {
+               Inset * inset = pit->getInset(pos);
                if (isEditableInset(inset)) {
                        UpdatableInset * uinset =
                                static_cast<UpdatableInset *>(inset);
@@ -221,29 +226,30 @@ void LyXText::setCharFont(Paragraph * par,
        }
 
        // Plug thru to version below:
-       setCharFont(buf, par, pos, font);
+       setCharFont(buf, pit, pos, font);
 }
 
 
-void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
+void LyXText::setCharFont(Buffer const * buf, ParagraphList::iterator pit,
                          pos_type pos, LyXFont const & fnt)
 {
        LyXFont font(fnt);
 
        LyXTextClass const & tclass = buf->params.getLyXTextClass();
-       LyXLayout_ptr const & layout = par->layout();
+       LyXLayout_ptr const & layout = pit->layout();
 
        // Get concrete layout font to reduce against
        LyXFont layoutfont;
 
-       if (pos < par->beginningOfBody())
+       if (pos < pit->beginningOfBody())
                layoutfont = layout->labelfont;
        else
                layoutfont = layout->font;
 
        // Realize against environment font information
-       if (par->getDepth()) {
-               Paragraph * tp = par;
+       if (pit->getDepth()) {
+#warning FIXME I think I hate this outerHood stuff.
+               Paragraph * tp = &*pit;
                while (!layoutfont.resolved() && tp && tp->getDepth()) {
                        tp = tp->outerHook();
                        if (tp)
@@ -256,7 +262,7 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
        // Now, reduce font against full layout font
        font.reduce(layoutfont);
 
-       par->setFont(pos, font);
+       pit->setFont(pos, font);
 }
 
 
@@ -546,10 +552,10 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
                LyXFont layoutfont;
                if (cursor.pos() < cursor.par()->beginningOfBody()) {
                        layoutfont = getLabelFont(bv()->buffer(),
-                                                 &*cursor.par());
+                                                 cursor.par());
                } else {
                        layoutfont = getLayoutFont(bv()->buffer(),
-                                                  &*cursor.par());
+                                                  cursor.par());
                }
                // Update current font
                real_current_font.update(font,
@@ -1768,7 +1774,7 @@ float LyXText::getCursorX(RowList::iterator rit,
                                font_metrics::width(
                                        rit->par()->layout()->labelsep,
                                        getLabelFont(bv()->buffer(),
-                                                    &*rit->par()));
+                                                    rit->par()));
                        if (rit->par()->isLineSeparator(body_pos - 1))
                                x -= singleWidth(rit->par(), body_pos - 1);
                }
@@ -1847,7 +1853,7 @@ void LyXText::setCurrentFont()
 
        current_font =
                cursor.par()->getFontSettings(bv()->buffer()->params, pos);
-       real_current_font = getFont(bv()->buffer(), &*cursor.par(), pos);
+       real_current_font = getFont(bv()->buffer(), cursor.par(), pos);
 
        if (cursor.pos() == cursor.par()->size() &&
            isBoundary(bv()->buffer(), &*cursor.par(), cursor.pos()) &&