]> git.lyx.org Git - lyx.git/blob - src/mathed/math_gridinset.C
fix typo that put too many include paths for most people
[lyx.git] / src / mathed / math_gridinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_gridinset.h"
6 #include "math_mathmlstream.h"
7 #include "math_streamstr.h"
8 #include "lyxfont.h"
9 #include "Painter.h"
10 #include "debug.h"
11
12
13 using std::swap;
14 using std::max;
15 using std::min;
16 using std::vector;
17
18
19 namespace {
20
21 string verboseHLine(int n)
22 {
23         string res;
24         for (int i = 0; i < n; ++i)
25                 res += "\\hline";
26         return res + ' ';
27 }
28
29 }
30
31
32 //////////////////////////////////////////////////////////////
33
34
35 MathGridInset::RowInfo::RowInfo()
36         : lines_(0), skip_(0)
37 {}
38
39
40
41 int MathGridInset::RowInfo::skipPixels() const
42 {
43 #ifdef WITH_WARNINGS
44 #warning fix this once the interface to LyXLength has improved
45 #endif
46         return int(crskip_.value());
47 }
48
49
50
51 //////////////////////////////////////////////////////////////
52
53
54 MathGridInset::ColInfo::ColInfo()
55         : align_('c'), leftline_(false), rightline_(false), lines_(0)
56 {}
57
58
59 //////////////////////////////////////////////////////////////
60
61
62 MathGridInset::MathGridInset(char v, string const & h)
63         : MathNestInset(guessColumns(h)), rowinfo_(2), colinfo_(guessColumns(h) + 1)
64 {
65         setDefaults();
66         valign(v);
67         halign(h);
68 }
69
70
71 MathGridInset::MathGridInset(col_type m, row_type n)
72         : MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_('c')
73 {
74         setDefaults();
75 }
76
77
78 MathGridInset::MathGridInset(col_type m, row_type n, char v, string const & h)
79         : MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_(v)
80 {
81         setDefaults();
82         valign(v);
83         halign(h);
84 }
85
86
87 MathInset * MathGridInset::clone() const
88 {
89         return new MathGridInset(*this);
90 }
91
92
93 MathInset::idx_type MathGridInset::index(row_type row, col_type col) const
94 {
95         return col + ncols() * row;
96 }
97
98
99 void MathGridInset::setDefaults()
100 {
101         if (ncols() <= 0)
102                 lyxerr << "positive number of columns expected\n";
103         if (nrows() <= 0)
104                 lyxerr << "positive number of rows expected\n";
105         for (col_type col = 0; col < ncols(); ++col) {
106                 colinfo_[col].align_ = defaultColAlign(col);
107                 colinfo_[col].skip_  = defaultColSpace(col);
108         }
109 }
110
111
112 void MathGridInset::halign(string const & hh)
113 {
114         col_type col = 0;
115         for (string::const_iterator it = hh.begin(); it != hh.end(); ++it) {
116                 char c = *it;
117                 if (c == '|') {
118                         colinfo_[col].lines_++;
119                 } else if (c == 'c' || c == 'l' || c == 'r') {
120                         colinfo_[col].align_ = c;
121                         ++col;
122                         colinfo_[col].lines_ = 0;
123                 } else {
124                         lyxerr << "unkown column separator: '" << c << "'\n";
125                 }
126         }
127
128 /*
129         col_type n = hh.size();
130         if (n > ncols())
131                 n = ncols();
132         for (col_type col = 0; col < n; ++col)
133                 colinfo_[col].align_ = hh[col];
134 */
135 }
136
137
138 MathGridInset::col_type MathGridInset::guessColumns(string const & hh) const
139 {
140         col_type col = 0;
141         for (string::const_iterator it = hh.begin(); it != hh.end(); ++it)
142                 if (*it == 'c' || *it == 'l' || *it == 'r')
143                         ++col;
144         return col;
145 }
146
147
148 void MathGridInset::halign(char h, col_type col)
149 {
150         colinfo_[col].align_ = h;
151 }
152
153
154 char MathGridInset::halign(col_type col) const
155 {
156         return colinfo_[col].align_;
157 }
158
159
160 string MathGridInset::halign() const
161 {
162         string res;
163         for (col_type col = 0; col < ncols(); ++col) {
164                 res += string(colinfo_[col].lines_, '|');
165                 res += colinfo_[col].align_;
166         }
167         return res + string(colinfo_[ncols()].lines_, '|');
168 }
169
170
171 void MathGridInset::valign(char c)
172 {
173         v_align_ = c;
174 }
175
176
177 char MathGridInset::valign() const
178 {
179         return v_align_;
180 }
181
182
183 MathGridInset::col_type MathGridInset::ncols() const
184 {
185         return colinfo_.size() - 1;
186 }
187
188
189 MathGridInset::row_type MathGridInset::nrows() const
190 {
191         return rowinfo_.size() - 1;
192 }
193
194
195 MathGridInset::col_type MathGridInset::col(idx_type idx) const
196 {
197         return idx % ncols();
198 }
199
200
201 MathGridInset::row_type MathGridInset::row(idx_type idx) const
202 {
203         return idx / ncols();
204 }
205
206
207 void MathGridInset::vcrskip(LyXLength const & crskip, row_type row)
208 {
209         rowinfo_[row].crskip_ = crskip;
210 }
211
212
213 LyXLength MathGridInset::vcrskip(row_type row) const
214 {
215         return rowinfo_[row].crskip_;
216 }
217
218
219 void MathGridInset::metrics(MathMetricsInfo const & mi) const
220 {
221         // let the cells adjust themselves
222         MathNestInset::metrics(mi);
223
224         // compute absolute sizes of vertical structure
225         for (row_type row = 0; row < nrows(); ++row) {
226                 int asc  = 0;
227                 int desc = 0;
228                 for (col_type col = 0; col < ncols(); ++col) {
229                         MathXArray const & c = xcell(index(row, col));
230                         asc  = max(asc,  c.ascent());
231                         desc = max(desc, c.descent());
232                 }
233                 rowinfo_[row].ascent_  = asc;
234                 rowinfo_[row].descent_ = desc;
235         }
236         rowinfo_[0].ascent_       += hlinesep() * rowinfo_[0].lines_;
237         rowinfo_[nrows()].ascent_  = 0;
238         rowinfo_[nrows()].descent_ = 0;
239
240         // compute vertical offsets
241         rowinfo_[0].offset_ = 0;
242         for (row_type row = 1; row <= nrows(); ++row) {
243                 rowinfo_[row].offset_  =
244                         rowinfo_[row - 1].offset_  +
245                         rowinfo_[row - 1].descent_ +
246                         rowinfo_[row - 1].skipPixels() +
247                         rowsep() +
248                         rowinfo_[row].lines_ * hlinesep() +
249                         rowinfo_[row].ascent_;
250         }
251
252         // adjust vertical offset
253         int h = 0;
254         switch (v_align_) {
255                 case 't':
256                         h = 0;
257                         break;
258                 case 'b':
259                         h = rowinfo_[nrows() - 1].offset_;
260                         break;
261                 default:
262                         h = rowinfo_[nrows() - 1].offset_ / 2;
263         }
264         for (row_type row = 0; row <= nrows(); ++row)
265                 rowinfo_[row].offset_ -= h;
266
267
268         // compute absolute sizes of horizontal structure
269         for (col_type col = 0; col < ncols(); ++col) {
270                 int wid = 0;
271                 for (row_type row = 0; row < nrows(); ++row)
272                         wid = max(wid, xcell(index(row, col)).width());
273                 colinfo_[col].width_ = wid;
274         }
275         colinfo_[ncols()].width_  = 0;
276
277         // compute horizontal offsets
278         colinfo_[0].offset_ = border();
279         for (col_type col = 1; col <= ncols(); ++col) {
280                 colinfo_[col].offset_ =
281                         colinfo_[col - 1].offset_ +
282                         colinfo_[col - 1].width_ +
283                         colinfo_[col - 1].skip_ +
284                         colsep() +
285                         colinfo_[col].lines_ * vlinesep();
286         }
287
288
289         width_   =   colinfo_[ncols() - 1].offset_
290                        + colinfo_[ncols() - 1].width_
291                  + vlinesep() * colinfo_[ncols()].lines_
292                        + border();
293
294         ascent_  = - rowinfo_[0].offset_
295                        + rowinfo_[0].ascent_
296                  + hlinesep() * rowinfo_[0].lines_
297                        + border();
298
299         descent_ =   rowinfo_[nrows() - 1].offset_
300                        + rowinfo_[nrows() - 1].descent_
301                  + hlinesep() * rowinfo_[nrows()].lines_
302                        + border();
303
304
305 /*
306         // Increase ws_[i] for 'R' columns (except the first one)
307         for (int i = 1; i < nc_; ++i)
308                 if (align_[i] == 'R')
309                         ws_[i] += 10 * df_width;
310         // Increase ws_[i] for 'C' column
311         if (align_[0] == 'C')
312                 if (ws_[0] < 7 * workwidth / 8)
313                         ws_[0] = 7 * workwidth / 8;
314
315         // Adjust local tabs
316         width = colsep();
317         for (cxrow = row_.begin(); cxrow; ++cxrow) {
318                 int rg = COLSEP;
319                 int lf = 0;
320                 for (int i = 0; i < nc_; ++i) {
321                         bool isvoid = false;
322                         if (cxrow->getTab(i) <= 0) {
323                                 cxrow->setTab(i, df_width);
324                                 isvoid = true;
325                         }
326                         switch (align_[i]) {
327                         case 'l':
328                                 lf = 0;
329                                 break;
330                         case 'c':
331                                 lf = (ws_[i] - cxrow->getTab(i))/2;
332                                 break;
333                         case 'r':
334                         case 'R':
335                                 lf = ws_[i] - cxrow->getTab(i);
336                                 break;
337                         case 'C':
338                                 if (cxrow == row_.begin())
339                                         lf = 0;
340                                 else if (cxrow.is_last())
341                                         lf = ws_[i] - cxrow->getTab(i);
342                                 else
343                                         lf = (ws_[i] - cxrow->getTab(i))/2;
344                                 break;
345                         }
346                         int const ww = (isvoid) ? lf : lf + cxrow->getTab(i);
347                         cxrow->setTab(i, lf + rg);
348                         rg = ws_[i] - ww + colsep();
349                         if (cxrow == row_.begin())
350                                 width += ws_[i] + colsep();
351                 }
352                 cxrow->setBaseline(cxrow->getBaseline() - ascent);
353         }
354 */
355 }
356
357
358 void MathGridInset::draw(Painter & pain, int x, int y) const
359 {
360         for (idx_type idx = 0; idx < nargs(); ++idx)
361                 xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx));
362
363         for (row_type row = 0; row <= nrows(); ++row)
364                 for (int i = 0; i < rowinfo_[row].lines_; ++i) {
365                         int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
366                                 - i * hlinesep() - hlinesep()/2 - rowsep()/2;
367                         pain.line(x + 1, yy, x + width_ - 1, yy);
368                 }
369
370         for (col_type col = 0; col <= ncols(); ++col)
371                 for (int i = 0; i < colinfo_[col].lines_; ++i) {
372                         int xx = x + colinfo_[col].offset_
373                                 - i * vlinesep() - vlinesep()/2 - colsep()/2;
374                         pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
375                 }
376 }
377
378
379 void MathGridInset::metricsT(TextMetricsInfo const & mi) const
380 {
381         // let the cells adjust themselves
382         //MathNestInset::metrics(mi);
383         for (idx_type i = 0; i < nargs(); ++i)
384                 xcell(i).metricsT(mi);
385
386         // compute absolute sizes of vertical structure
387         for (row_type row = 0; row < nrows(); ++row) {
388                 int asc  = 0;
389                 int desc = 0;
390                 for (col_type col = 0; col < ncols(); ++col) {
391                         MathXArray const & c = xcell(index(row, col));
392                         asc  = max(asc,  c.ascent());
393                         desc = max(desc, c.descent());
394                 }
395                 rowinfo_[row].ascent_  = asc;
396                 rowinfo_[row].descent_ = desc;
397         }
398         //rowinfo_[0].ascent_       += hlinesep() * rowinfo_[0].lines_;
399         rowinfo_[nrows()].ascent_  = 0;
400         rowinfo_[nrows()].descent_ = 0;
401
402         // compute vertical offsets
403         rowinfo_[0].offset_ = 0;
404         for (row_type row = 1; row <= nrows(); ++row) {
405                 rowinfo_[row].offset_  =
406                         rowinfo_[row - 1].offset_  +
407                         rowinfo_[row - 1].descent_ +
408                         //rowinfo_[row - 1].skipPixels() +
409                         1 + //rowsep() +
410                         //rowinfo_[row].lines_ * hlinesep() +
411                         rowinfo_[row].ascent_;
412         }
413
414         // adjust vertical offset
415         int h = 0;
416         switch (v_align_) {
417                 case 't':
418                         h = 0;
419                         break;
420                 case 'b':
421                         h = rowinfo_[nrows() - 1].offset_;
422                         break;
423                 default:
424                         h = rowinfo_[nrows() - 1].offset_ / 2;
425         }
426         for (row_type row = 0; row <= nrows(); ++row)
427                 rowinfo_[row].offset_ -= h;
428
429
430         // compute absolute sizes of horizontal structure
431         for (col_type col = 0; col < ncols(); ++col) {
432                 int wid = 0;
433                 for (row_type row = 0; row < nrows(); ++row)
434                         wid = max(wid, xcell(index(row, col)).width());
435                 colinfo_[col].width_ = wid;
436         }
437         colinfo_[ncols()].width_  = 0;
438
439         // compute horizontal offsets
440         colinfo_[0].offset_ = border();
441         for (col_type col = 1; col <= ncols(); ++col) {
442                 colinfo_[col].offset_ =
443                         colinfo_[col - 1].offset_ +
444                         colinfo_[col - 1].width_ +
445                         colinfo_[col - 1].skip_ +
446                         1 ; //colsep() +
447                         //colinfo_[col].lines_ * vlinesep();
448         }
449
450
451         width_   =   colinfo_[ncols() - 1].offset_
452                        + colinfo_[ncols() - 1].width_
453                  //+ vlinesep() * colinfo_[ncols()].lines_
454                        + 2;
455
456         ascent_  = - rowinfo_[0].offset_
457                        + rowinfo_[0].ascent_
458                  //+ hlinesep() * rowinfo_[0].lines_
459                        + 1;
460
461         descent_ =   rowinfo_[nrows() - 1].offset_
462                        + rowinfo_[nrows() - 1].descent_
463                  //+ hlinesep() * rowinfo_[nrows()].lines_
464                        + 1;
465
466 }
467
468
469 void MathGridInset::drawT(TextPainter & pain, int x, int y) const
470 {
471         for (idx_type idx = 0; idx < nargs(); ++idx)
472                 xcell(idx).drawT(pain, x + cellXOffset(idx), y + cellYOffset(idx));
473 }
474
475
476 string MathGridInset::eolString(row_type row) const
477 {
478         string eol;
479
480         if (!rowinfo_[row].crskip_.zero())
481                 eol += "[" + rowinfo_[row].crskip_.asLatexString() + "]";
482
483         // make sure an upcoming '[' does not break anything
484         if (row + 1 < nrows()) {
485                 MathArray const & c = cell(index(row + 1, 0));
486                 if (c.size() && c.front()->getChar() == '[')
487                         //eol += "[0pt]";
488                         eol += "{}";
489         }
490
491         // only add \\ if necessary
492         if (eol.empty() && row + 1 == nrows())
493                 return string();
494
495         return "\\\\" + eol + '\n';
496 }
497
498
499 string MathGridInset::eocString(col_type col) const
500 {
501         if (col + 1 == ncols())
502                 return string();
503         return " & ";
504 }
505
506
507 void MathGridInset::addRow(row_type row)
508 {
509         rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
510         cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
511 }
512
513
514 void MathGridInset::appendRow()
515 {
516         rowinfo_.push_back(RowInfo());
517         //cells_.insert(cells_.end(), ncols(), MathXArray());
518         for (col_type col = 0; col < ncols(); ++col)
519                 cells_.push_back(cells_type::value_type());
520 }
521
522
523 void MathGridInset::delRow(row_type row)
524 {
525         if (nrows() == 1)
526                 return;
527
528         cells_type::iterator it = cells_.begin() + row * ncols();
529         cells_.erase(it, it + ncols());
530
531         rowinfo_.erase(rowinfo_.begin() + row);
532 }
533
534
535 void MathGridInset::addCol(col_type newcol)
536 {
537         const col_type nc = ncols();
538         const row_type nr = nrows();
539         cells_type new_cells((nc + 1) * nr);
540
541         for (row_type row = 0; row < nr; ++row)
542                 for (col_type col = 0; col < nc; ++col)
543                         new_cells[row * (nc + 1) + col + (col > newcol)]
544                                 = cells_[row * nc + col];
545         swap(cells_, new_cells);
546
547         ColInfo inf;
548         inf.skip_  = defaultColSpace(newcol);
549         inf.align_ = defaultColAlign(newcol);
550         colinfo_.insert(colinfo_.begin() + newcol, inf);
551 }
552
553
554 void MathGridInset::delCol(col_type col)
555 {
556         if (ncols() == 1)
557                 return;
558
559         cells_type tmpcells;
560         for (col_type i = 0; i < nargs(); ++i)
561                 if (i % ncols() != col)
562                         tmpcells.push_back(cells_[i]);
563         swap(cells_, tmpcells);
564
565         colinfo_.erase(colinfo_.begin() + col);
566 }
567
568
569 int MathGridInset::cellXOffset(idx_type idx) const
570 {
571         col_type c = col(idx);
572         int x = colinfo_[c].offset_;
573         char align = colinfo_[c].align_;
574         if (align == 'r' || align == 'R')
575                 x += colinfo_[c].width_ - xcell(idx).width();
576         if (align == 'c' || align == 'C')
577                 x += (colinfo_[c].width_ - xcell(idx).width()) / 2;
578         return x;
579 }
580
581
582 int MathGridInset::cellYOffset(idx_type idx) const
583 {
584         return rowinfo_[row(idx)].offset_;
585 }
586
587
588 bool MathGridInset::idxUpDown(idx_type & idx, bool up) const
589 {
590         if (up) {
591                 if (idx < ncols())
592                         return false;
593                 idx -= ncols();
594                 return true;
595         } else {
596                 if (idx >= ncols() * (nrows() - 1))
597                         return false;
598                 idx += ncols();
599                 return true;
600         }
601 }
602
603
604 bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
605 {
606         // leave matrix if on the left hand edge
607         if (col(idx) == 0)
608                 return false;
609         --idx;
610         pos = cell(idx).size();
611         return true;
612 }
613
614
615 bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
616 {
617         // leave matrix if on the right hand edge
618         if (col(idx) + 1 == ncols())
619                 return false;
620         ++idx;
621         pos = 0;
622         return true;
623 }
624
625
626 bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
627 {
628         switch (v_align_) {
629                 case 't':
630                         idx = 0;
631                         break;
632                 case 'b':
633                         idx = (nrows() - 1) * ncols();
634                         break;
635                 default:
636                         idx = ((nrows() - 1) / 2) * ncols();
637         }
638         pos = 0;
639         return true;
640 }
641
642
643 bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
644 {
645         switch (v_align_) {
646                 case 't':
647                         idx = ncols() - 1;
648                         break;
649                 case 'b':
650                         idx = nargs() - 1;
651                         break;
652                 default:
653                         idx = ((nrows() - 1) / 2 + 1) * ncols() - 1;
654         }
655         pos = cell(idx).size();
656         return true;
657 }
658
659
660 bool MathGridInset::idxHome(idx_type & idx, pos_type & pos) const
661 {
662         if (pos > 0) {
663                 pos = 0;
664                 return true;
665         }
666         if (col(idx) > 0) {
667                 idx -= idx % ncols();
668                 pos = 0;
669                 return true;
670         }
671         if (idx > 0) {
672                 idx = 0;
673                 pos = 0;
674                 return true;
675         }
676         return false;
677 }
678
679
680 bool MathGridInset::idxEnd(idx_type & idx, pos_type & pos) const
681 {
682         if (pos < cell(idx).size()) {
683                 pos = cell(idx).size();
684                 return true;
685         }
686         if (col(idx) < ncols() - 1) {
687                 idx = idx - idx % ncols() + ncols() - 1;
688                 pos = cell(idx).size();
689                 return true;
690         }
691         if (idx < nargs() - 1) {
692                 idx = nargs() - 1;
693                 pos = cell(idx).size();
694                 return true;
695         }
696         return false;
697 }
698
699
700 bool MathGridInset::idxDelete(idx_type & idx)
701 {
702         // nothing to do if we are in the middle of the last row of the inset
703         if (idx + ncols() > nargs())
704                 return false;
705
706         // try to delete entire sequence of ncols() empty cells if possible
707         for (idx_type i = idx; i < idx + ncols(); ++i)
708                 if (cell(i).size())
709                         return false;
710
711         // move cells if necessary
712         for (idx_type i = index(row(idx), 0); i < idx; ++i)
713                 cell(i).swap(cell(i + ncols()));
714
715         delRow(row(idx));
716
717         if (idx >= nargs())
718                 idx = nargs() - 1;
719
720         // undo effect of Ctrl-Tab (i.e. pull next cell)
721         //if (idx + 1 != nargs())
722         //      cell(idx).swap(cell(idx + 1));
723
724         // we handled the event..
725         return true;
726 }
727
728
729 // reimplement old behaviour when pressing Delete in the last position
730 // of a cell
731 void MathGridInset::idxGlue(idx_type idx)
732 {
733         col_type c = col(idx);
734         if (c + 1 == ncols()) {
735                 if (row(idx) + 1 != nrows()) {
736                         for (col_type cc = 0; cc < ncols(); ++cc)
737                                 cell(idx).push_back(cell(idx + cc + 1));
738                         delRow(row(idx) + 1);
739                 }
740         } else {
741                 cell(idx).push_back(cell(idx + 1));
742                 for (col_type cc = c + 2; cc < ncols(); ++cc)
743                         cell(idx - c + cc - 1) = cell(idx - c + cc);
744                 cell(idx - c + ncols() - 1).erase();
745         }
746 }
747
748
749 MathGridInset::RowInfo const & MathGridInset::rowinfo(row_type row) const
750 {
751         return rowinfo_[row];
752 }
753
754
755 MathGridInset::RowInfo & MathGridInset::rowinfo(row_type row)
756 {
757         return rowinfo_[row];
758 }
759
760
761 vector<MathInset::idx_type>
762         MathGridInset::idxBetween(idx_type from, idx_type to) const
763 {
764         row_type r1 = min(row(from), row(to));
765         row_type r2 = max(row(from), row(to));
766         col_type c1 = min(col(from), col(to));
767         col_type c2 = max(col(from), col(to));
768         vector<idx_type> res;
769         for (row_type i = r1; i <= r2; ++i)
770                 for (col_type j = c1; j <= c2; ++j)
771                         res.push_back(index(i, j));
772         return res;
773 }
774
775
776
777 void MathGridInset::normalize(NormalStream & os) const
778 {
779         os << "[grid ";
780         for (row_type row = 0; row < nrows(); ++row) {
781                 os << "[row ";
782                 for (col_type col = 0; col < ncols(); ++col)
783                         os << "[cell " << cell(index(row, col)) << ']';
784                 os << ']';
785         }
786         os << ']';
787 }
788
789
790 void MathGridInset::mathmlize(MathMLStream & os) const
791 {
792         os << MTag("mtable");
793         for (row_type row = 0; row < nrows(); ++row) {
794                 os << MTag("mtr");
795                 for (col_type col = 0; col < ncols(); ++col)
796                         os << cell(index(row, col));
797                 os << ETag("mtr");
798         }
799         os << ETag("mtable");
800 }
801
802
803 void MathGridInset::write(WriteStream & os) const
804 {
805         for (row_type row = 0; row < nrows(); ++row) {
806                 os << verboseHLine(rowinfo_[row].lines_);
807                 for (col_type col = 0; col < ncols(); ++col)
808                         os << cell(index(row, col)) << eocString(col);
809                 os << eolString(row);
810         }
811         string const s = verboseHLine(rowinfo_[nrows()].lines_);
812         if (!s.empty() && s != " ")
813                 os << "\\\\" << s;
814 }
815
816
817 int MathGridInset::colsep() const
818 {
819         return 6;
820 }
821
822
823 int MathGridInset::rowsep() const
824 {
825         return 6;
826 }
827
828
829 int MathGridInset::hlinesep() const
830 {
831         return 3;
832 }
833
834
835 int MathGridInset::vlinesep() const
836 {
837         return 3;
838 }
839
840
841 int MathGridInset::border() const
842 {
843         return 2;
844 }