]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathSplit.cpp
... and RELEASE-NOTES
[lyx.git] / src / mathed / InsetMathSplit.cpp
index 5929e273030d69c4689a9a195d0afd0788f585d3..e385e0a09ac3c3d735592d5bc7e8620278aff5ae 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "MathData.h"
 #include "MathStream.h"
-#include "MathStream.h"
+#include "MathSupport.h"
 
 #include "FuncRequest.h"
 #include "FuncStatus.h"
@@ -87,6 +87,17 @@ char InsetMathSplit::displayColAlign(idx_type idx) const
 }
 
 
+int InsetMathSplit::displayColSpace(col_type col) const
+{
+       if (name_ == "split" || name_ == "aligned" || name_ == "align")
+               return colSpace(hullAlign, col);
+       if (name_ == "alignedat")
+               return colSpace(hullAlignAt, col);
+       return 0;
+}
+
+
+
 void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
 {
        InsetMathGrid::draw(pi, x, y);
@@ -130,9 +141,19 @@ void InsetMathSplit::write(WriteStream & ws) const
                suffix = from_ascii("*");
        ws << "\\begin{" << name_ << suffix << '}';
        bool open = ws.startOuterRow();
-       if (name_ != "split" && name_ != "align" && verticalAlignment() != 'c')
-               ws << '[' << verticalAlignment() << ']';
-       if (name_ == "alignedat")
+       bool const hasArg(name_ == "alignedat");
+       if (name_ != "split" && name_ != "align") {
+               if (verticalAlignment() != 'c')
+                       ws << '[' << verticalAlignment() << ']';
+               else if (!hasArg) {
+                       docstring const first(asString(cell(0)));
+                       // prevent misinterpretation of the first character of
+                       // the first cell as optional argument (bug 10361)
+                       if (!first.empty() && first[0] == '[')
+                               ws << "[]";
+               }
+       }
+       if (hasArg)
                ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
        InsetMathGrid::write(ws);
        if (ws.fragile())