]> git.lyx.org Git - lyx.git/blob - src/mathed/math_splitinset.C
the clone auto_ptr patch
[lyx.git] / src / mathed / math_splitinset.C
1 #include "math_splitinset.h"
2 #include "math_mathmlstream.h"
3 #include "math_streamstr.h"
4
5 using std::auto_ptr;
6
7
8 MathSplitInset::MathSplitInset(string const & name)
9         : MathGridInset(1, 1), name_(name)
10 {
11         setDefaults();
12 }
13
14
15 auto_ptr<InsetBase> MathSplitInset::clone() const
16 {
17         return auto_ptr<InsetBase>(new MathSplitInset(*this));
18 }
19
20
21 char MathSplitInset::defaultColAlign(col_type col)
22 {
23         if (name_ == "split")
24                 return 'l';
25         if (name_ == "gathered")
26                 return 'c';
27         if (name_ == "aligned")
28                 return (col & 1) ? 'l' : 'r';
29         return 'l';
30 }
31
32
33 void MathSplitInset::write(WriteStream & ws) const
34 {
35         if (ws.fragile())
36                 ws << "\\protect";
37         ws << "\\begin{" << name_ << '}';
38         MathGridInset::write(ws);
39         if (ws.fragile())
40                 ws << "\\protect";
41         ws << "\\end{" << name_ << "}\n";
42 }