]> git.lyx.org Git - lyx.git/commitdiff
small stuff, whitespace & consistent naming
authorAndré Pönitz <poenitz@gmx.net>
Tue, 21 Oct 2003 16:15:14 +0000 (16:15 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 21 Oct 2003 16:15:14 +0000 (16:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7942 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/FuncStatus.C
src/FuncStatus.h
src/insets/insetbase.C
src/insets/insetbibitem.C
src/insets/insettabular.C
src/insets/mailinset.C
src/lyxfont.C
src/lyxfont.h
src/lyxfunc.C
src/lyxrow_funcs.C
src/lyxtext.h
src/paragraph.C
src/text.C
src/text2.C

index 9c83203b66e4192a2cc9fd5952ac5890478d3f99..1998db67d1d0a9f81311606931c334c578d9137e 100644 (file)
@@ -17,56 +17,56 @@ FuncStatus::FuncStatus() : v_(OK)
 }
 
 
-FuncStatus & FuncStatus::clear ()
+void FuncStatus::clear()
 {
        v_ = OK;
-       return *this;
 }
 
-void FuncStatus::operator |= (FuncStatus const & f)
+
+void FuncStatus::operator|=(FuncStatus const & f)
 {
        v_ |= f.v_;
 }
 
-FuncStatus & FuncStatus::unknown (bool b)
+
+void FuncStatus::unknown(bool b)
 {
        if (b)
                v_ |= UNKNOWN;
        else
                v_ &= !UNKNOWN;
-       return *this;
 }
 
 
-bool FuncStatus::unknown () const
+
+bool FuncStatus::unknown() const
 {
        return (v_ & UNKNOWN);
 }
 
 
-FuncStatus & FuncStatus::disabled (bool b)
+void FuncStatus::disabled(bool b)
 {
        if (b)
                v_ |= DISABLED;
        else
                v_ &= !DISABLED;
-       return *this;
 }
 
 
-bool FuncStatus::disabled () const
+bool FuncStatus::disabled() const
 {
        return (v_ & DISABLED);
 }
 
 
-void FuncStatus::setOnOff (bool b)
+void FuncStatus::setOnOff(bool b)
 {
        v_ |= (b ? ON : OFF);
 }
 
 
-bool FuncStatus::onoff (bool b) const
+bool FuncStatus::onoff(bool b) const
 {
        if (b)
                return (v_ & ON);
index 8375c3401e99c5b89670ceeb98754d37987f1530..80613c26478479fb97e232b07ea26a6ffe0a0011 100644 (file)
@@ -37,23 +37,23 @@ public:
        ///
        FuncStatus();
        //
-       FuncStatus & clear ();
+       void clear();
        ///
-       void operator |= (FuncStatus const & f);
+       void operator|=(FuncStatus const & f);
        ///
-       FuncStatus & unknown(bool b);
+       void unknown(bool b);
        ///
        bool unknown() const;
 
        ///
-       FuncStatus & disabled (bool b);
+       void disabled(bool b);
        ///
-       bool disabled () const;
+       bool disabled() const;
 
        ///
-       void setOnOff (bool b);
+       void setOnOff(bool b);
        ///
-       bool onoff (bool b) const;
+       bool onoff(bool b) const;
 };
 
 #endif
index 572ab221bd2df8754e5fbdc72dd6eab978cc9d36..4c8a6022be1dcda608c70f8a8e0ac650a9277d16 100644 (file)
@@ -19,6 +19,7 @@ InsetBase::dispatch(FuncRequest const & f, idx_type & i, pos_type & p)
        return priv_dispatch(f, i, p);
 }
 
+
 dispatch_result
 InsetBase::dispatch(FuncRequest const & f)
 {
index 8f4274b95cad00795597ccbc23add316a5d0179b..1eb749e3a81e47152bff2d47a3a8976abb6f86c5 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Full author contact details are available in file CREDITS.
  */
+
 #include <config.h>
 
 #include "insetbibitem.h"
index 350b9a6812cd6644eccca1f75dc67e8fbca65756..477bb3d4d921d3574073017eb0f475c78719e1cc 100644 (file)
@@ -2057,7 +2057,8 @@ FuncStatus InsetTabular::getStatus(string const & what) const
        }
        if (action == LyXTabular::LAST_ACTION) {
                status.clear();
-               return status.unknown(true);
+               status.unknown(true);
+               return status;
        }
 
        string const argument
@@ -2085,7 +2086,8 @@ FuncStatus InsetTabular::getStatus(string const & what) const
        case LyXTabular::DELETE_COLUMN:
        case LyXTabular::SET_ALL_LINES:
        case LyXTabular::UNSET_ALL_LINES:
-               return status.clear();
+               status.clear();
+               return status;
 
        case LyXTabular::MULTICOLUMN:
                status.setOnOff(tabular.isMultiColumn(actcell));
index c7861f0f7e9dee2fc05b4a9f6df9fbe5609bdf29..d9995ca2d71ffb99ceeea9dacf8026d0057ac709 100644 (file)
@@ -29,7 +29,7 @@ void MailInset::showDialog(BufferView * bv) const
 void MailInset::updateDialog(BufferView * bv) const
 {
        BOOST_ASSERT(bv);
-       if(bv->owner()->getDialogs().visible(name()))
+       if (bv->owner()->getDialogs().visible(name()))
                bv->owner()->getDialogs().update(name(),
                                                 inset2string(*bv->buffer()));
 }
index fc79dc34d085a0d281e5b80fa9b243603237bda9..8ddc66ad54080466f2492fc8822ff531945c3619 100644 (file)
@@ -25,7 +25,6 @@
 #include "lyxrc.h"
 
 #include "support/lstrings.h"
-
 #include "support/std_sstream.h"
 
 using lyx::support::ascii_lowercase;
@@ -946,7 +945,23 @@ LyXFont::FONT_SHAPE LyXFont::realShape() const
 }
 
 
-ostream & operator<<(ostream & o, LyXFont::FONT_MISC_STATE fms)
+ostream & operator<<(ostream & os, LyXFont::FONT_MISC_STATE fms)
+{
+       return os << int(fms);
+}
+
+
+std::ostream & operator<<(std::ostream & os, LyXFont const & font)
 {
-       return o << int(fms);
+       return os << "font:"
+               << " family " << font.bits.family
+               << " series " << font.bits.series
+               << " shape " << font.bits.shape
+               << " size " << font.bits.size
+               << " color " << font.bits.color
+               << " emph " << font.bits.emph
+               << " underbar " << font.bits.underbar
+               << " noun " << font.bits.noun
+               << " number " << font.bits.number
+               << " lang: " << (font.lang ? font.lang->lang() : 0);
 }
index ab683b4e1c33fa32b7862b45d93e814c05f97096..488932d208f592e52bd8299aa101b0bfb9c8c9be 100644 (file)
@@ -289,7 +289,7 @@ public:
        int latexWriteStartChanges(std::ostream &, LyXFont const & base,
                                   LyXFont const & prev) const;
 
-       /** Writes tha tail of the LaTeX needed to chagne to this font.
+       /** Writes the tail of the LaTeX needed to change to this font.
            Returns number of chars written. Base is the font state we want
            to achieve.
        */
@@ -305,6 +305,9 @@ public:
        ///
        friend
        bool operator==(LyXFont const & font1, LyXFont const & font2);
+       ///
+       friend
+       std::ostream & operator<<(std::ostream & os, LyXFont const & font);
 
        /// Converts logical attributes to concrete shape attribute
        LyXFont::FONT_SHAPE realShape() const;
@@ -335,22 +338,16 @@ public:
                FONT_MISC_STATE number;
        };
 private:
-
        ///
        FontBits bits;
-
        ///
        Language const * lang;
-
        /// Sane font
        static FontBits sane;
-
        /// All inherit font
        static FontBits inherit;
-
        /// All ignore font
        static FontBits ignore;
-
        /// Updates a misc setting according to request
        LyXFont::FONT_MISC_STATE setMisc(LyXFont::FONT_MISC_STATE newfont,
                                         LyXFont::FONT_MISC_STATE org);
@@ -362,10 +359,14 @@ private:
  *  having to expose lyxfont.h.
  */
 class LyXFont_size {
-        LyXFont::FONT_SIZE val_;
 public:
+       ///
        LyXFont_size(LyXFont::FONT_SIZE val) : val_(val) {}
-        operator LyXFont::FONT_SIZE() const{ return val_; }
+       ///
+       operator LyXFont::FONT_SIZE() const { return val_; }
+private:
+       ///
+       LyXFont::FONT_SIZE val_;
 };
 
 
@@ -444,8 +445,7 @@ bool operator!=(LyXFont::FontBits const & lhs, LyXFont::FontBits const & rhs)
 inline
 bool operator==(LyXFont const & font1, LyXFont const & font2)
 {
-       return font1.bits == font2.bits &&
-               font1.lang == font2.lang;
+       return font1.bits == font2.bits && font1.lang == font2.lang;
 }
 
 ///
index d1b6a02da943d53b45b59d833623de0b12b7f235..7939f8eb839df0fc7526afeeb740531de55f248a 100644 (file)
@@ -278,7 +278,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
 
        if (ev.action == LFUN_NOACTION) {
                setStatusMessage(N_("Nothing to do"));
-               return flag.disabled(true);
+               flag.disabled(true);
+               return flag;
        }
 
        switch (ev.action) {
@@ -318,7 +319,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        // no
                        setStatusMessage(N_("Command not allowed with"
                                            "out any document open"));
-                       return flag.disabled(true);
+                       flag.disabled(true);
+                       return flag;
                }
        }
 
index e7af3d086fa557af4a56c55700e8efb9b65df7db..035aba648ac73dd35b11f09b71ea975fa0abb680 100644 (file)
@@ -61,10 +61,9 @@ int numberOfHfills(Paragraph const & par, Row const & row)
        pos_type first = row.pos();
 
        // hfill *DO* count at the beginning of paragraphs!
-       if (first) {
+       if (first)
                while (first < last && par.isHfill(first))
                        ++first;
-       }
 
        first = max(first, par.beginningOfBody());
 
@@ -88,10 +87,9 @@ int numberOfLabelHfills(Paragraph const & par, Row const & row)
        pos_type first = row.pos();
 
        // hfill *DO* count at the beginning of paragraphs!
-       if (first) {
+       if (first)
                while (first < last && par.isHfill(first))
                        ++first;
-       }
 
        last = min(last, par.beginningOfBody());
        int n = 0;
index 9035a26cad172c5d5eb880b9f44b55a78f7c9010..ff2d28552e4be13e3bedec153c966c1b05443c6a 100644 (file)
@@ -66,7 +66,7 @@ public:
        /// our buffer's default layout font
        LyXFont defaultfont_;
 private:
-       /// offset of dran area to document start.
+       /// offset of drawn area to document start.
        int anchor_y_;
 public:
        /// update all cached row positions
index 00de5af8dd59f28e93b03e7729613740cf2fba4f..253a617e706b6fd1adebe28155fa42f6def03c15 100644 (file)
@@ -374,12 +374,12 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams, pos_type pos,
        else
                layoutfont = lout->font;
 
-       LyXFont tmpfont = getFontSettings(bparams, pos);
-       tmpfont.realize(layoutfont);
-       tmpfont.realize(outerfont);
-       tmpfont.realize(bparams.getLyXTextClass().defaultfont());
+       LyXFont font = getFontSettings(bparams, pos);
+       font.realize(layoutfont);
+       font.realize(outerfont);
+       font.realize(bparams.getLyXTextClass().defaultfont());
 
-       return tmpfont;
+       return font;
 }
 
 
index 9760a8a60aa6ba0d2748932137c4ebf3594fa780..c89e60e6362367bbab0e5658ca30e15a8172656f 100644 (file)
@@ -201,7 +201,7 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
 
        // The most common case is handled first (Asger)
        if (IsPrintable(c)) {
-               if (font.language()->RightToLeft()) {
+               if (!font.language()->RightToLeft()) {
                        if ((lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
                             lyxrc.font_norm_type == LyXRC::ISO_10646_1)
                            && font.language()->lang() == "arabic") {
@@ -234,35 +234,25 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
 
 lyx::pos_type LyXText::log2vis(lyx::pos_type pos) const
 {
-       if (bidi_start == -1)
-               return pos;
-       else
-               return log2vis_list[pos - bidi_start];
+       return (bidi_start == -1) ? pos : log2vis_list[pos - bidi_start];
 }
 
 
 lyx::pos_type LyXText::vis2log(lyx::pos_type pos) const
 {
-       if (bidi_start == -1)
-               return pos;
-       else
-               return vis2log_list[pos - bidi_start];
+       return (bidi_start == -1) ? pos : vis2log_list[pos - bidi_start];
 }
 
 
 lyx::pos_type LyXText::bidi_level(lyx::pos_type pos) const
 {
-       if (bidi_start == -1)
-               return 0;
-       else
-               return bidi_levels[pos - bidi_start];
+       return (bidi_start == -1) ? 0 : bidi_levels[pos - bidi_start];
 }
 
 
 bool LyXText::bidi_InRange(lyx::pos_type pos) const
 {
-       return bidi_start == -1 ||
-               (bidi_start <= pos && pos <= bidi_end);
+       return bidi_start == -1 || (bidi_start <= pos && pos <= bidi_end);
 }
 
 
@@ -327,7 +317,6 @@ void LyXText::computeBidiTables(Paragraph const & par,
                        is_space = false;
                }
 
-
                bool new_rtl = font.isVisibleRightToLeft();
                bool new_rtl0 = font.isRightToLeft();
                int new_level;
@@ -402,8 +391,8 @@ bool LyXText::isBoundary(Buffer const & buf, Paragraph const & par,
                return false;
 
        if (!bidi_InRange(pos - 1)) {
-               /// This can happen if pos is the first char of a row.
-               /// Returning false in this case is incorrect!
+               // This can happen if pos is the first char of a row.
+               // Returning false in this case is incorrect!
                return false;
        }
 
@@ -1086,7 +1075,6 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
                                prev->getLabelWidthString() == pit->getLabelWidthString())
                        {
                                layoutasc = (layout->itemsep * defaultRowHeight());
-//                     } else if (rit != firstRow()) {
                        } else if (pit != ownerParagraphs().begin() || row.pos() != 0) {
                                tmptop = layout->topsep;
 
@@ -1485,7 +1473,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit,
                        // par, does not end in newline, and is not row above a
                        // display inset... then stretch it
                        if (ns
-                               && next_row != pit->rows.end()
+                               && rit->end() < pit->size()
                                && !pit->isNewline(next_row->pos() - 1)
                                && !disp_inset
                                ) {
@@ -1619,7 +1607,8 @@ void LyXText::rejectChange()
 WordLangTuple const LyXText::selectNextWordToSpellcheck(float & value)
 {
        if (the_locking_inset) {
-               WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value);
+               WordLangTuple word =
+                       the_locking_inset->selectNextWordToSpellcheck(bv(), value);
                if (!word.word().empty()) {
                        value += float(cursor.y());
                        value /= float(height);
@@ -1700,8 +1689,7 @@ WordLangTuple const LyXText::selectNextWordToSpellcheck(float & value)
        // Finally, we copy the word to a string and return it
        string str;
        if (selection.cursor.pos() < cursor.pos()) {
-               pos_type i;
-               for (i = selection.cursor.pos(); i < cursor.pos(); ++i) {
+               for (pos_type i = selection.cursor.pos(); i < cursor.pos(); ++i) {
                        if (!cursorPar()->isInset(i))
                                str += cursorPar()->getChar(i);
                }
@@ -1748,8 +1736,6 @@ void LyXText::deleteWordForward()
                selection.cursor = cursor;
                cursor = tmpcursor;
                setSelection();
-
-               // Great, CutSelection() gets rid of multiple spaces.
                cutSelection(true, false);
        }
 }
@@ -2158,11 +2144,7 @@ int LyXText::redoParagraphInternal(ParagraphList::iterator pit)
                z = rowBreakPoint(pit, row) + 1;
                row.end(z);
                pit->rows.push_back(row);
-       }
-
-       RowList::iterator rit = pit->rows.begin();
-       RowList::iterator end = pit->rows.end();
-       for (rit = pit->rows.begin(); rit != end; ++rit) {
+               RowList::iterator rit = boost::prior(pit->rows.end());
                int const f = fill(pit, *rit, ww);
                int const w = ww - f;
                par_width = std::max(par_width, w);
@@ -2210,8 +2192,8 @@ void LyXText::fullRebreak()
 
 void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
 {
-       //lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
-       //      << " workWidth: " << workWidth() << endl;
+       lyxerr << "LyXText::metrics: width: " << mi.base.textwidth
+               << " workWidth: " << workWidth() << "\nfont: " << mi.base.font << endl;
        //BOOST_ASSERT(mi.base.textwidth);
 
        // rebuild row cache
index 3215791e6400794c8dcd93e1b14f9576094bcd6e..6df04db2c6ffd39936dcfa646c0ee07fc50490f6 100644 (file)
@@ -113,47 +113,37 @@ LyXFont LyXText::getFont(ParagraphList::iterator pit, pos_type pos) const
        LyXLayout_ptr const & layout = pit->layout();
 #warning broken?
        BufferParams const & params = bv()->buffer()->params();
+       pos_type const body_pos = pit->beginningOfBody();
 
        // We specialize the 95% common case:
        if (!pit->getDepth()) {
-               if (layout->labeltype == LABEL_MANUAL
-                   && pos < pit->beginningOfBody()) {
-                       // 1% goes here
-                       LyXFont f = pit->getFontSettings(params, pos);
-                       if (pit->inInset())
-                               pit->inInset()->getDrawFont(f);
+               LyXFont f = pit->getFontSettings(params, pos);
+               if (pit->inInset())
+                       pit->inInset()->getDrawFont(f);
+               if (layout->labeltype == LABEL_MANUAL && pos < body_pos)
                        return f.realize(layout->reslabelfont);
-               } else {
-                       LyXFont f = pit->getFontSettings(params, pos);
-                       if (pit->inInset())
-                               pit->inInset()->getDrawFont(f);
+               else
                        return f.realize(layout->resfont);
-               }
        }
 
        // The uncommon case need not be optimized as much
-
        LyXFont layoutfont;
-
-       if (pos < pit->beginningOfBody()) {
-               // 1% goes here
+       if (pos < body_pos)
                layoutfont = layout->labelfont;
-       } else {
-               // 99% goes here
+       else
                layoutfont = layout->font;
-       }
 
-       LyXFont tmpfont = pit->getFontSettings(params, pos);
-       tmpfont.realize(layoutfont);
+       LyXFont font = pit->getFontSettings(params, pos);
+       font.realize(layoutfont);
 
        if (pit->inInset())
-               pit->inInset()->getDrawFont(tmpfont);
+               pit->inInset()->getDrawFont(font);
 
        // Realize with the fonts of lesser depth.
-       tmpfont.realize(outerFont(pit, ownerParagraphs()));
-       tmpfont.realize(defaultfont_);
+       //font.realize(outerFont(pit, ownerParagraphs()));
+       font.realize(defaultfont_);
 
-       return tmpfont;
+       return font;
 }
 
 
@@ -166,7 +156,7 @@ LyXFont LyXText::getLayoutFont(ParagraphList::iterator pit) const
 
        LyXFont font = layout->font;
        // Realize with the fonts of lesser depth.
-       font.realize(outerFont(pit, ownerParagraphs()));
+       //font.realize(outerFont(pit, ownerParagraphs()));
        font.realize(defaultfont_);
 
        return font;
@@ -549,7 +539,6 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
 
 // the cursor set functions have a special mechanism. When they
 // realize, that you left an empty paragraph, they will delete it.
-// They also delete the corresponding row
 
 // need the selection cursor:
 void LyXText::setSelection()