From: André Pönitz Date: Mon, 18 Jul 2005 12:57:08 +0000 (+0000) Subject: 3 more percents... X-Git-Tag: 1.6.10~14026 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7856f2c683c562ef563e7a04055a324f3b7cc58b;p=features.git 3 more percents... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10323 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 7e3cd21e28..deebec57b7 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1177,7 +1177,7 @@ InsetTabular::idx_type InsetTabular::getNearestCell(int x, int y) const { idx_type idx_min = 0; int dist_min = std::numeric_limits::max(); - for (idx_type i = 0; i < nargs(); ++i) { + for (idx_type i = 0, n = nargs(); i != n; ++i) { if (theCoords.getInsets().has(tabular.getCellInset(i).get())) { int const d = dist(i, x, y); if (d < dist_min) { @@ -1795,12 +1795,6 @@ void InsetTabular::getSelection(LCursor & cur, } -size_t InsetTabular::nargs() const -{ - return tabular.getNumberOfCells(); -} - - LyXText * InsetTabular::getText(int idx) const { return size_t(idx) < nargs() ? cell(idx)->getText(0) : 0; diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 7b8830a47d..3a421375eb 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -106,7 +106,7 @@ public: /// Appends \c list with all labels found within this inset. void getLabelList(Buffer const &, std::vector & list) const; /// number of cells - size_t nargs() const; + size_t nargs() const { return tabular.getNumberOfCells(); } /// boost::shared_ptr cell(idx_type) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index cf1b64320f..61ce57fe8a 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -406,12 +406,6 @@ void InsetText::setViewCache(BufferView const * bv) const } -LyXText * InsetText::getText(int i) const -{ - return (i == 0) ? const_cast(&text_) : 0; -} - - void InsetText::appendParagraphs(Buffer * buffer, ParagraphList & plist) { #ifdef WITH_WARNINGS diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 639591c1fd..65bdbedd8e 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -100,7 +100,9 @@ public: /// Appends \c list with all labels found within this inset. void getLabelList(Buffer const &, std::vector & list) const; /// - LyXText * getText(int) const; + LyXText * getText(int i) const { + return (i == 0) ? const_cast(&text_) : 0; + } /// bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const; diff --git a/src/paragraph.C b/src/paragraph.C index 1c8905a331..36eafed96a 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -300,20 +300,6 @@ bool Paragraph::insetAllowed(InsetBase_code code) } -InsetBase * Paragraph::getInset(pos_type pos) -{ - BOOST_ASSERT(pos < size()); - return insetlist.get(pos); -} - - -InsetBase const * Paragraph::getInset(pos_type pos) const -{ - BOOST_ASSERT(pos < size()); - return insetlist.get(pos); -} - - // Gets uninstantiated font setting at position. LyXFont const Paragraph::getFontSettings(BufferParams const & bparams, pos_type pos) const @@ -1466,26 +1452,6 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, } -namespace { - -/// return true if the char is a meta-character for an inset -inline -bool IsInsetChar(char c) -{ - return (c == Paragraph::META_INSET); -} - -} // namespace anon - - - -bool Paragraph::isHfill(pos_type pos) const -{ - return isInset(pos) - && getInset(pos)->lyxCode() == InsetBase::HFILL_CODE; -} - - bool Paragraph::isNewline(pos_type pos) const { return isInset(pos) @@ -1493,17 +1459,11 @@ bool Paragraph::isNewline(pos_type pos) const } -bool Paragraph::isSeparator(pos_type pos) const -{ - return IsSeparatorChar(getChar(pos)); -} - - bool Paragraph::isLineSeparator(pos_type pos) const { value_type const c = getChar(pos); return IsLineSeparatorChar(c) - || (IsInsetChar(c) && getInset(pos) && + || (c == Paragraph::META_INSET && getInset(pos) && getInset(pos)->isLineSeparator()); } diff --git a/src/paragraph.h b/src/paragraph.h index 9eeef130fb..83337fbd14 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -323,23 +323,27 @@ public: /// bool insetAllowed(InsetBase_code code); /// - InsetBase * getInset(lyx::pos_type pos); - /// - InsetBase const * getInset(lyx::pos_type pos) const; + InsetBase * getInset(lyx::pos_type pos) { + return insetlist.get(pos); + } /// - InsetList insetlist; - + InsetBase const * getInset(lyx::pos_type pos) const { + return insetlist.get(pos); + } /// - bool isHfill(lyx::pos_type pos) const; + bool isHfill(lyx::pos_type pos) const { + return isInset(pos) + && getInset(pos)->lyxCode() == InsetBase::HFILL_CODE; + } /// hinted by profiler bool isInset(lyx::pos_type pos) const { return getChar(pos) == static_cast(META_INSET); } /// bool isNewline(lyx::pos_type pos) const; - /// - bool isSeparator(lyx::pos_type pos) const; + /// return true if the char is a word separator + bool isSeparator(lyx::pos_type pos) const { return getChar(pos) == ' '; } /// bool isLineSeparator(lyx::pos_type pos) const; /// True if the character/inset at this point can be part of a word @@ -389,6 +393,11 @@ public: /// dump some information to lyxerr void dump() const; + +public: + /// + InsetList insetlist; + private: /// cached dimensions of paragraph Dimension dim_; @@ -405,6 +414,7 @@ private: /// end of label lyx::pos_type begin_of_body_; + /// Pimpl away stuff class Pimpl; /// friend class Paragraph::Pimpl; diff --git a/src/support/textutils.h b/src/support/textutils.h index 19867e79ed..8c0ba08e8c 100644 --- a/src/support/textutils.h +++ b/src/support/textutils.h @@ -15,13 +15,6 @@ #ifndef TEXTUTILS_H #define TEXTUTILS_H -/// return true if the char is a word separator -inline -bool IsSeparatorChar(char c) -{ - return c == ' '; -} - /// return true if the char is a line separator inline