]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathXYMatrix.C
Avoid processing empty lines when reading the symbols file
[lyx.git] / src / mathed / InsetMathXYMatrix.C
1 /**
2  * \file InsetMathXYMatrix.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathXYMatrix.h"
14 #include "MathStream.h"
15
16 #include "LaTeXFeatures.h"
17 #include "support/std_ostream.h"
18
19
20 namespace lyx {
21
22
23 InsetMathXYMatrix::InsetMathXYMatrix(LyXLength const & s, char c)
24         : InsetMathGrid(1, 1), spacing_(s), spacing_code_(c)
25 {}
26
27
28 std::auto_ptr<InsetBase> InsetMathXYMatrix::doClone() const
29 {
30         return std::auto_ptr<InsetBase>(new InsetMathXYMatrix(*this));
31 }
32
33
34 int InsetMathXYMatrix::colsep() const
35 {
36         return 40;
37 }
38
39
40 int InsetMathXYMatrix::rowsep() const
41 {
42         return 40;
43 }
44
45
46 void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const
47 {
48         if (mi.base.style == LM_ST_DISPLAY)
49                 mi.base.style = LM_ST_TEXT;
50         InsetMathGrid::metrics(mi, dim);
51 }
52
53
54 void InsetMathXYMatrix::write(WriteStream & os) const
55 {
56         os << "\\xymatrix";
57         switch (spacing_code_) {
58         case 'R':
59         case 'C':
60         case 'M':
61         case 'W':
62         case 'H':
63         case 'L':
64                 os << '@' << spacing_code_ << '='
65                    << from_ascii(spacing_.asLatexString());
66                 break;
67         default:
68                 if (!spacing_.empty())
69                         os << "@=" << from_ascii(spacing_.asLatexString());
70         }
71         os << '{';
72         InsetMathGrid::write(os);
73         os << "}\n";
74 }
75
76
77 void InsetMathXYMatrix::infoize(odocstream & os) const
78 {
79         os << "xymatrix ";
80         switch (spacing_code_) {
81         case 'R':
82         case 'C':
83         case 'M':
84         case 'W':
85         case 'H':
86         case 'L':
87                 os << spacing_code_ << ' '
88                    << from_ascii(spacing_.asLatexString()) << ' ';
89                 break;
90         default:
91                 if (!spacing_.empty())
92                         os << from_ascii(spacing_.asLatexString()) << ' ';
93         }
94         InsetMathGrid::infoize(os);
95 }
96
97
98 void InsetMathXYMatrix::normalize(NormalStream & os) const
99 {
100         os << "[xymatrix ";
101         InsetMathGrid::normalize(os);
102         os << ']';
103 }
104
105
106 void InsetMathXYMatrix::maple(MapleStream & os) const
107 {
108         os << "xymatrix(";
109         InsetMathGrid::maple(os);
110         os << ')';
111 }
112
113
114 void InsetMathXYMatrix::validate(LaTeXFeatures & features) const
115 {
116         features.require("xy");
117         InsetMathGrid::validate(features);
118 }
119
120
121 } // namespace lyx