]> git.lyx.org Git - features.git/commitdiff
Small Inset isXXX methods cleanup
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jul 2013 08:55:52 +0000 (10:55 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 25 Jun 2014 15:54:26 +0000 (17:54 +0200)
 * rename isStretchableSpace to isHfill
 * inline a trivial method
 * remove InsetIPAMacro::isLineSeparator, which has the same value as default.

src/Paragraph.cpp
src/TextMetrics.cpp
src/insets/Inset.h
src/insets/InsetIPAMacro.cpp
src/insets/InsetIPAMacro.h
src/insets/InsetSpace.cpp
src/insets/InsetSpace.h

index f3040b5da1559c39b5a431f460270749fa9d8421..c33712d416e2bf583ddbfbb40ae07c11ca9c6452 100644 (file)
@@ -3200,8 +3200,7 @@ docstring Paragraph::simpleLyXHTMLOnePar(Buffer const & buf,
 bool Paragraph::isHfill(pos_type pos) const
 {
        Inset const * inset = getInset(pos);
-       return inset && (inset->lyxCode() == SPACE_CODE &&
-                        inset->isStretchableSpace());
+       return inset && inset->isHfill();
 }
 
 
index 090e503cdc669ed9564e290d62b3407ee917bbbd..befa7eb010011402b352158553ef320f471cce0e 100644 (file)
@@ -672,8 +672,7 @@ void TextMetrics::computeRowMetrics(pit_type const pit,
        InsetList::const_iterator iend = par.insetList().end();
        for ( ; ii != iend; ++ii) {
                if (ii->pos >= endpos || ii->pos < row.pos()
-                       || (ii->inset->lyxCode() != SPACE_CODE ||
-                           !ii->inset->isStretchableSpace()))
+                   || !ii->inset->isHfill())
                        continue;
                Dimension dim = row.dimension();
                if (pm.hfillExpansion(row, ii->pos))
index 63834eb6a0da8f195473e93e0e2600152876c97d..5fcc892dba96cd2a8417f806434e4ad5f9afc708 100644 (file)
@@ -431,8 +431,8 @@ public:
        /// is this equivalent to a space (which is BTW different from
        /// a line separator)?
        virtual bool isSpace() const { return false; }
-       /// is this an expandible space (rubber length)?
-       virtual bool isStretchableSpace() const { return false; }
+       /// does this inset try to use all available space (like \\hfill does)?
+       virtual bool isHfill() const { return false; }
 
        enum DisplayType {
                Inline = 0,
index 46d75194ef70b31b52c5f02493267f2bae7a1902..7d5290d565158d5f59678821b9c49bc6bcac98e4 100644 (file)
@@ -620,16 +620,4 @@ void InsetIPAChar::validate(LaTeXFeatures & features) const
 }
 
 
-bool InsetIPAChar::isLetter() const
-{
-       return true;
-}
-
-
-bool InsetIPAChar::isLineSeparator() const
-{
-       return false;
-}
-
-
 } // namespace lyx
index ff07b4009c03f0461fd3896c7dfcdbdc4bbbbb53..dbcfc541abcae5d51f9cf0f108c7e7df1a63e881 100644 (file)
@@ -167,9 +167,7 @@ public:
        /// should this inset be handled like a normal character?
        bool isChar() const { return true; }
        /// is this equivalent to a letter?
-       bool isLetter() const;
-       /// should we break lines after this inset?
-       bool isLineSeparator() const;
+       bool isLetter() const { return true; }
 private:
        Inset * clone() const { return new InsetIPAChar(*this); }
 
index f7a1cd92ae8fc511171d61904e5266c9b13f7e91..4066e3954a91dd3f377838451826c74c6d8c38ae 100644 (file)
@@ -199,7 +199,7 @@ int const arrow_size = 8;
 
 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       if (isStretchableSpace()) {
+       if (isHfill()) {
                // The metrics for this kinds are calculated externally in
                // \c TextMetrics::computeRowMetrics. Those are dummy value:
                dim = Dimension(10, 10, 10);
@@ -240,7 +240,7 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
                        break;
                case InsetSpaceParams::CUSTOM:
                case InsetSpaceParams::CUSTOM_PROTECTED: {
-                       int const w = 
+                       int const w =
                                params_.length.len().inPixels(mi.base.textwidth,
                                                        fm.width(char_type('M')));
                        int const minw = (w < 0) ? 3 * arrow_size : 4;
@@ -267,7 +267,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
 {
        Dimension const dim = dimension(*pi.base.bv);
 
-       if (isStretchableSpace() || params_.length.len().value() < 0) {
+       if (isHfill() || params_.length.len().value() < 0) {
                int const asc = theFontMetrics(pi.base.font).ascent('M');
                int const desc = theFontMetrics(pi.base.font).descent('M');
                // Pixel height divisible by 2 for prettier fill graphics:
@@ -459,7 +459,7 @@ void InsetSpaceParams::write(ostream & os) const
                os <<  "\\hspace*{}";
                break;
        }
-       
+
        if (!length.len().empty())
                os << "\n\\length " << length.asString();
 }
@@ -837,7 +837,7 @@ void InsetSpace::forOutliner(docstring & os, size_t) const
 }
 
 
-bool InsetSpace::isStretchableSpace() const
+bool InsetSpace::isHfill() const
 {
        return params_.kind == InsetSpaceParams::HFILL
                || params_.kind == InsetSpaceParams::HFILL_PROTECTED
index 8055706c41118b0f0df5599710eae187ef1611f9..b5a628a4561326581105297fe15b692d40a3b9a1 100644 (file)
@@ -142,9 +142,8 @@ public:
        bool clickable(int, int) const { return true; }
        ///
        InsetCode lyxCode() const { return SPACE_CODE; }
-       /// is this an expandible space (rubber length)?
-       bool isStretchableSpace() const;
-
+       /// does this inset try to use all available space (like \\hfill does)?
+       bool isHfill() const;
        /// should this inset be handled like a normal character?
        bool isChar() const { return true; }
        /// is this equivalent to a letter?