commit 696ea82b21f5f0729e14bdefe90d8e18563ddf2e
Author: Enrico Forestieri <for...@lyx.org>
Date:   Tue Oct 25 00:49:26 2016 +0200

    Factor out common code used to underline/strike out math
    
    Also use the exact amount of vertical space TeX adds after a
    math display (instead of 1ex) for vertically shifting the box.
    We have to use \belowdisplayshortskip here, instead of
    \belowdisplayskip, because the math formula is typeset by alone
    in a box, and thus there is no following line.
---
 src/mathed/InsetMathHull.cpp |   67 ++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 345ee44..2bb8822 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -121,6 +121,37 @@ namespace {
        }
 
 
+       // writes a preamble for underlined or struck out math display
+       void writeMathdisplayPreamble(WriteStream & os)
+       {
+               if (os.strikeoutMath()) {
+                       if (os.ulemCmd() == WriteStream::UNDERLINE)
+                               os << "\\raisebox{-\\belowdisplayshortskip}{"
+                                     
"\\lyxmathsout{\\parbox[b]{\\columnwidth}{";
+                       else
+                               os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
+               } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+                       os << "\\raisebox{-\\belowdisplayshortskip}{"
+                             "\\parbox[b]{\\columnwidth}{";
+               else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+                       os << "\\parbox{\\columnwidth}{";
+       }
+
+
+       // writes a postamble for underlined or struck out math display
+       void writeMathdisplayPostamble(WriteStream & os)
+       {
+               if (os.strikeoutMath()) {
+                       if (os.ulemCmd() == WriteStream::UNDERLINE)
+                               os << "}";
+                       os << "}}\\\\\n";
+               } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+                       os << "}}\\\\\n";
+               else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+                       os << "}\\\\\n";
+       }
+
+
 } // end anon namespace
 
 
@@ -1029,14 +1060,7 @@ void InsetMathHull::header_write(WriteStream & os) const
                break;
 
        case hullEquation:
-               if (os.strikeoutMath()) {
-                       if (os.ulemCmd() == WriteStream::UNDERLINE)
-                               os << "\\raisebox{1ex}{";
-                       os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
-               } else if (os.ulemCmd() == WriteStream::UNDERLINE)
-                       os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
-               else if (os.ulemCmd() == WriteStream::STRIKEOUT)
-                       os << "\\parbox{\\columnwidth}{";
+               writeMathdisplayPreamble(os);
                os << "\n";
                os.startOuterRow();
                if (n)
@@ -1050,14 +1074,7 @@ void InsetMathHull::header_write(WriteStream & os) const
        case hullFlAlign:
        case hullGather:
        case hullMultline:
-               if (os.strikeoutMath()) {
-                       if (os.ulemCmd() == WriteStream::UNDERLINE)
-                               os << "\\raisebox{1ex}{";
-                       os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
-               } else if (os.ulemCmd() == WriteStream::UNDERLINE)
-                       os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
-               else if (os.ulemCmd() == WriteStream::STRIKEOUT)
-                       os << "\\parbox{\\columnwidth}{";
+               writeMathdisplayPreamble(os);
                os << "\n";
                os.startOuterRow();
                os << "\\begin{" << hullName(type_) << star(n) << "}\n";
@@ -1113,14 +1130,7 @@ void InsetMathHull::footer_write(WriteStream & os) const
                        os << "\\end{equation" << star(n) << "}\n";
                else
                        os << "\\]\n";
-               if (os.strikeoutMath()) {
-                       if (os.ulemCmd() == WriteStream::UNDERLINE)
-                               os << "}";
-                       os << "}}\\\\\n";
-               } else if (os.ulemCmd() == WriteStream::UNDERLINE)
-                       os << "}}\\\\\n";
-               else if (os.ulemCmd() == WriteStream::STRIKEOUT)
-                       os << "}\\\\\n";
+               writeMathdisplayPostamble(os);
                break;
 
        case hullEqnArray:
@@ -1131,14 +1141,7 @@ void InsetMathHull::footer_write(WriteStream & os) const
                os << "\n";
                os.startOuterRow();
                os << "\\end{" << hullName(type_) << star(n) << "}\n";
-               if (os.strikeoutMath()) {
-                       if (os.ulemCmd() == WriteStream::UNDERLINE)
-                               os << "}";
-                       os << "}}\\\\\n";
-               } else if (os.ulemCmd() == WriteStream::UNDERLINE)
-                       os << "}}\\\\\n";
-               else if (os.ulemCmd() == WriteStream::STRIKEOUT)
-                       os << "}\\\\\n";
+               writeMathdisplayPostamble(os);
                break;
 
        case hullAlignAt:

Reply via email to