]> git.lyx.org Git - lyx.git/blob - src/insets/InsetTabular.h
Properly fix bug 3258.
[lyx.git] / src / insets / InsetTabular.h
1 // -*- C++ -*-
2 /**
3  * \file InsetTabular.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jürgen Vigna
8  * \author Lars Gullik Bjønnes
9  * \author Matthias Ettrich
10  * \author André Pönitz
11  * \author Jürgen Vigna
12  *
13  * Full author contact details are available in file CREDITS.
14  */
15
16
17 // This is Juergen's rewrite of the tabular (table) support.
18
19 // Things to think of when designing the new tabular support:
20 // - color support (colortbl, color)
21 // - decimal alignment (dcloumn)
22 // - custom lines (hhline)
23 // - rotation
24 // - multicolumn
25 // - multirow
26 // - column styles
27
28 // This is what I have written about tabular support in the LyX3-Tasks file:
29 //
30 //  o rewrite of table code. Should probably be written as some
31 //    kind of an inset. [Done]
32 // o enhance longtable support
33
34 // Lgb
35
36 #ifndef INSETTABULAR_H
37 #define INSETTABULAR_H
38
39 #include "Inset.h"
40 #include "MailInset.h"
41 #include "Length.h"
42 #include "InsetText.h"
43
44
45 #include <boost/shared_ptr.hpp>
46
47 #include <iosfwd>
48 #include <vector>
49
50 namespace lyx {
51
52 class FuncStatus;
53 class Lexer;
54 class BufferView;
55 class Buffer;
56 class BufferParams;
57 class Paragraph;
58 class CursorSlice;
59
60 namespace frontend { class Painter; }
61
62
63 class InsetTabular;
64 class Cursor;
65 class OutputParams;
66
67 //
68 // A helper struct for tables
69 //
70 class Tabular  {
71 public:
72         ///
73         enum Feature {
74                 ///
75                 APPEND_ROW = 0,
76                 ///
77                 APPEND_COLUMN,
78                 ///
79                 DELETE_ROW,
80                 ///
81                 DELETE_COLUMN,
82                 ///
83                 COPY_ROW,
84                 ///
85                 COPY_COLUMN,
86                 ///
87                 TOGGLE_LINE_TOP,
88                 ///
89                 TOGGLE_LINE_BOTTOM,
90                 ///
91                 TOGGLE_LINE_LEFT,
92                 ///
93                 TOGGLE_LINE_RIGHT,
94                 ///
95                 ALIGN_LEFT,
96                 ///
97                 ALIGN_RIGHT,
98                 ///
99                 ALIGN_CENTER,
100                 ///
101                 ALIGN_BLOCK,
102                 ///
103                 VALIGN_TOP,
104                 ///
105                 VALIGN_BOTTOM,
106                 ///
107                 VALIGN_MIDDLE,
108                 ///
109                 M_TOGGLE_LINE_TOP,
110                 ///
111                 M_TOGGLE_LINE_BOTTOM,
112                 ///
113                 M_TOGGLE_LINE_LEFT,
114                 ///
115                 M_TOGGLE_LINE_RIGHT,
116                 ///
117                 M_ALIGN_LEFT,
118                 ///
119                 M_ALIGN_RIGHT,
120                 ///
121                 M_ALIGN_CENTER,
122                 ///
123                 M_VALIGN_TOP,
124                 ///
125                 M_VALIGN_BOTTOM,
126                 ///
127                 M_VALIGN_MIDDLE,
128                 ///
129                 MULTICOLUMN,
130                 ///
131                 SET_ALL_LINES,
132                 ///
133                 UNSET_ALL_LINES,
134                 ///
135                 SET_LONGTABULAR,
136                 ///
137                 UNSET_LONGTABULAR,
138                 ///
139                 SET_PWIDTH,
140                 ///
141                 SET_MPWIDTH,
142                 ///
143                 SET_ROTATE_TABULAR,
144                 ///
145                 UNSET_ROTATE_TABULAR,
146                 ///
147                 TOGGLE_ROTATE_TABULAR,
148                 ///
149                 SET_ROTATE_CELL,
150                 ///
151                 UNSET_ROTATE_CELL,
152                 ///
153                 TOGGLE_ROTATE_CELL,
154                 ///
155                 SET_USEBOX,
156                 ///
157                 SET_LTHEAD,
158                 UNSET_LTHEAD,
159                 ///
160                 SET_LTFIRSTHEAD,
161                 UNSET_LTFIRSTHEAD,
162                 ///
163                 SET_LTFOOT,
164                 UNSET_LTFOOT,
165                 ///
166                 SET_LTLASTFOOT,
167                 UNSET_LTLASTFOOT,
168                 ///
169                 SET_LTNEWPAGE,
170                 ///
171                 SET_SPECIAL_COLUMN,
172                 ///
173                 SET_SPECIAL_MULTI,
174                 ///
175                 SET_BOOKTABS,
176                 ///
177                 UNSET_BOOKTABS,
178                 ///
179                 SET_TOP_SPACE,
180                 ///
181                 SET_BOTTOM_SPACE,
182                 ///
183                 SET_INTERLINE_SPACE,
184                 ///
185                 LAST_ACTION
186         };
187         ///
188         enum {
189                 ///
190                 CELL_NORMAL = 0,
191                 ///
192                 CELL_BEGIN_OF_MULTICOLUMN,
193                 ///
194                 CELL_PART_OF_MULTICOLUMN
195         };
196
197         ///
198         enum VAlignment {
199                 ///
200                 LYX_VALIGN_TOP = 0,
201                 ///
202                 LYX_VALIGN_BOTTOM = 1,
203                 ///
204                 LYX_VALIGN_MIDDLE = 2
205         };
206
207         enum BoxType {
208                 ///
209                 BOX_NONE = 0,
210                 ///
211                 BOX_PARBOX = 1,
212                 ///
213                 BOX_MINIPAGE = 2
214         };
215
216         class ltType {
217         public:
218                 // constructor
219                 ltType();
220                 // we have this header type (is set in the getLT... functions)
221                 bool set;
222                 // double borders on top
223                 bool topDL;
224                 // double borders on bottom
225                 bool bottomDL;
226                 // used for FirstHeader & LastFooter and if this is true
227                 // all the rows marked as FirstHeader or LastFooter are
228                 // ignored in the output and it is set to be empty!
229                 bool empty;
230         };
231
232         /// type for row numbers
233         typedef size_t row_type;
234         /// type for column numbers
235         typedef size_t col_type;
236         /// type for cell indices
237         typedef size_t idx_type;
238         /// index indicating an invalid position
239         static const idx_type npos = static_cast<idx_type>(-1);
240
241         /// constructor
242         Tabular(BufferParams const &, col_type columns_arg,
243                    row_type rows_arg);
244
245         /// Returns true if there is a topline, returns false if not
246         bool topLine(idx_type cell, bool wholerow = false) const;
247         /// Returns true if there is a topline, returns false if not
248         bool bottomLine(idx_type cell, bool wholerow = false) const;
249         /// Returns true if there is a topline, returns false if not
250         bool leftLine(idx_type cell, bool wholecolumn = false) const;
251         /// Returns true if there is a topline, returns false if not
252         bool rightLine(idx_type cell, bool wholecolumn = false) const;
253
254         ///
255         bool topAlreadyDrawn(idx_type cell) const;
256         ///
257         bool leftAlreadyDrawn(idx_type cell) const;
258         ///
259         bool isLastRow(idx_type cell) const;
260
261         /// return space occupied by the second horizontal line and
262         /// interline space above row \p row in pixels
263         int getAdditionalHeight(row_type row) const;
264         ///
265         int getAdditionalWidth(idx_type cell) const;
266
267         /* returns the maximum over all rows */
268         ///
269         int getWidthOfColumn(idx_type cell) const;
270         ///
271         int getWidthOfTabular() const;
272         ///
273         int getAscentOfRow(row_type row) const;
274         ///
275         int getDescentOfRow(row_type row) const;
276         ///
277         int getHeightOfTabular() const;
278         ///
279         void setAscentOfRow(row_type row, int height);
280         ///
281         void setDescentOfRow(row_type row, int height);
282         ///
283         void setWidthOfCell(idx_type cell, int new_width);
284         ///
285         void setAllLines(idx_type cell, bool line);
286         ///
287         void setTopLine(idx_type cell, bool line, bool wholerow = false);
288         ///
289         void setBottomLine(idx_type cell, bool line, bool wholerow = false);
290         ///
291         void setLeftLine(idx_type cell, bool line, bool wholecolumn = false);
292         ///
293         void setRightLine(idx_type cell, bool line, bool wholecolumn = false);
294         ///
295         void setAlignment(idx_type cell, LyXAlignment align,
296                           bool onlycolumn = false);
297         ///
298         void setVAlignment(idx_type cell, VAlignment align,
299                            bool onlycolumn = false);
300         ///
301         void setColumnPWidth(Cursor &, idx_type, Length const &);
302         ///
303         bool setMColumnPWidth(Cursor &, idx_type, Length const &);
304         ///
305         void setAlignSpecial(idx_type cell, docstring const & special,
306                              Feature what);
307         ///
308         LyXAlignment getAlignment(idx_type cell,
309                                   bool onlycolumn = false) const;
310         ///
311         VAlignment getVAlignment(idx_type cell,
312                                  bool onlycolumn = false) const;
313         ///
314         Length const getPWidth(idx_type cell) const;
315         ///
316         Length const getColumnPWidth(idx_type cell) const;
317         ///
318         Length const getMColumnPWidth(idx_type cell) const;
319         ///
320         docstring const getAlignSpecial(idx_type cell, int what) const;
321         ///
322         int getWidthOfCell(idx_type cell) const;
323         ///
324         int getBeginningOfTextInCell(idx_type cell) const;
325         ///
326         void appendRow(BufferParams const &, idx_type cell);
327         ///
328         void deleteRow(row_type row);
329         ///
330         void copyRow(BufferParams const &, row_type);
331         ///
332         void appendColumn(BufferParams const &, idx_type cell);
333         ///
334         void deleteColumn(col_type column);
335         ///
336         void copyColumn(BufferParams const &, col_type);
337         ///
338         bool isFirstCellInRow(idx_type cell) const;
339         ///
340         idx_type getFirstCellInRow(row_type row) const;
341         ///
342         bool isLastCellInRow(idx_type cell) const;
343         ///
344         idx_type getLastCellInRow(row_type row) const;
345         ///
346         idx_type getNumberOfCells() const;
347         ///
348         idx_type numberOfCellsInRow(idx_type cell) const;
349         ///
350         void write(Buffer const &, std::ostream &) const;
351         ///
352         void read(Buffer const &, Lexer &);
353         ///
354         int latex(Buffer const &, odocstream &, OutputParams const &) const;
355         //
356         int docbook(Buffer const & buf, odocstream & os, OutputParams const &) const;
357         ///
358         void plaintext(Buffer const &, odocstream &,
359                        OutputParams const & runparams, int const depth,
360                        bool onlydata, unsigned char delim) const;
361         ///
362         bool isMultiColumn(idx_type cell) const;
363         ///
364         bool isMultiColumnReal(idx_type cell) const;
365         ///
366         void setMultiColumn(Buffer *, idx_type cell, idx_type number);
367         ///
368         idx_type unsetMultiColumn(idx_type cell); // returns number of new cells
369         ///
370         bool isPartOfMultiColumn(row_type row, col_type column) const;
371         ///
372         row_type row_of_cell(idx_type cell) const;
373         ///
374         col_type column_of_cell(idx_type cell) const;
375         ///
376         col_type right_column_of_cell(idx_type cell) const;
377         ///
378         void setBookTabs(bool);
379         ///
380         bool useBookTabs() const;
381         ///
382         void setLongTabular(bool);
383         ///
384         bool isLongTabular() const;
385         ///
386         void setRotateTabular(bool);
387         ///
388         bool getRotateTabular() const;
389         ///
390         void setRotateCell(idx_type cell, bool);
391         ///
392         bool getRotateCell(idx_type cell) const;
393         ///
394         bool needRotating() const;
395         ///
396         bool isLastCell(idx_type cell) const;
397         ///
398         idx_type getCellAbove(idx_type cell) const;
399         ///
400         idx_type getCellBelow(idx_type cell) const;
401         ///
402         idx_type getLastCellAbove(idx_type cell) const;
403         ///
404         idx_type getLastCellBelow(idx_type cell) const;
405         ///
406         idx_type getCellNumber(row_type row, col_type column) const;
407         ///
408         void setUsebox(idx_type cell, BoxType);
409         ///
410         BoxType getUsebox(idx_type cell) const;
411         //
412         // Long Tabular Options support functions
413         ///
414         bool checkLTType(row_type row, ltType const &) const;
415         ///
416         void setLTHead(row_type row, bool flag, ltType const &, bool first);
417         ///
418         bool getRowOfLTHead(row_type row, ltType &) const;
419         ///
420         bool getRowOfLTFirstHead(row_type row, ltType &) const;
421         ///
422         void setLTFoot(row_type row, bool flag, ltType const &, bool last);
423         ///
424         bool getRowOfLTFoot(row_type row, ltType &) const;
425         ///
426         bool getRowOfLTLastFoot(row_type row, ltType &) const;
427         ///
428         void setLTNewPage(row_type row, bool what);
429         ///
430         bool getLTNewPage(row_type row) const;
431         ///
432         bool haveLTHead() const;
433         ///
434         bool haveLTFirstHead() const;
435         ///
436         bool haveLTFoot() const;
437         ///
438         bool haveLTLastFoot() const;
439         ///
440         // end longtable support
441         ///
442         boost::shared_ptr<InsetText> getCellInset(idx_type cell) const;
443         ///
444         boost::shared_ptr<InsetText> getCellInset(row_type row,
445                                                   col_type column) const;
446         ///
447         void setCellInset(row_type row, col_type column,
448                           boost::shared_ptr<InsetText>) const;
449         /// Search for \param inset in the tabular, with the
450         ///
451         idx_type getCellFromInset(Inset const * inset) const;
452         ///
453         row_type rows() const { return rows_; }
454         ///
455         col_type columns() const { return columns_;}
456         ///
457         void validate(LaTeXFeatures &) const;
458         ///
459 //private:
460         ///
461         class cellstruct {
462         public:
463                 ///
464                 cellstruct(BufferParams const &);
465                 ///
466                 cellstruct(cellstruct const &);
467                 ///
468                 cellstruct & operator=(cellstruct);
469                 ///
470                 void swap(cellstruct & rhs);
471                 ///
472                 idx_type cellno;
473                 ///
474                 int width_of_cell;
475                 ///
476                 int multicolumn;
477                 ///
478                 LyXAlignment alignment;
479                 ///
480                 VAlignment valignment;
481                 ///
482                 bool top_line;
483                 ///
484                 bool bottom_line;
485                 ///
486                 bool left_line;
487                 ///
488                 bool right_line;
489                 ///
490                 BoxType usebox;
491                 ///
492                 bool rotate;
493                 ///
494                 docstring align_special;
495                 ///
496                 Length p_width; // this is only set for multicolumn!!!
497                 ///
498                 boost::shared_ptr<InsetText> inset;
499         };
500         cellstruct & cellinfo_of_cell(idx_type cell) const;
501         ///
502         typedef std::vector<cellstruct> cell_vector;
503         ///
504         typedef std::vector<cell_vector> cell_vvector;
505
506         ///
507         class rowstruct {
508         public:
509                 ///
510                 rowstruct();
511                 ///
512                 int ascent_of_row;
513                 ///
514                 int descent_of_row;
515                 ///
516                 bool top_line;
517                 ///
518                 bool bottom_line;
519                 /// Extra space between the top line and this row
520                 Length top_space;
521                 /// Ignore top_space if true and use the default top space
522                 bool top_space_default;
523                 /// Extra space between this row and the bottom line
524                 Length bottom_space;
525                 /// Ignore bottom_space if true and use the default bottom space
526                 bool bottom_space_default;
527                 /// Extra space between the bottom line and the next top line
528                 Length interline_space;
529                 /// Ignore interline_space if true and use the default interline space
530                 bool interline_space_default;
531                 /// This are for longtabulars only
532                 /// a row of endhead
533                 bool endhead;
534                 /// a row of endfirsthead
535                 bool endfirsthead;
536                 /// a row of endfoot
537                 bool endfoot;
538                 /// row of endlastfoot
539                 bool endlastfoot;
540                 /// row for a pagebreak
541                 bool newpage;
542         };
543         ///
544         typedef std::vector<rowstruct> row_vector;
545
546         ///
547         class columnstruct {
548                 public:
549                 ///
550                 columnstruct();
551                 ///
552                 LyXAlignment alignment;
553                 ///
554                 VAlignment valignment;
555                 ///
556                 bool left_line;
557                 ///
558                 bool right_line;
559                 ///
560                 int  width_of_column;
561                 ///
562                 Length p_width;
563                 ///
564                 docstring align_special;
565         };
566         ///
567         typedef std::vector<columnstruct> column_vector;
568
569         ///
570         row_type rows_;
571         ///
572         col_type columns_;
573         ///
574         idx_type numberofcells;
575         ///
576         std::vector<row_type> rowofcell;
577         ///
578         std::vector<col_type> columnofcell;
579         ///
580         row_vector row_info;
581         ///
582         column_vector column_info;
583         ///
584         mutable cell_vvector cell_info;
585         ///
586         int width_of_tabular;
587         ///
588         bool use_booktabs;
589         ///
590         bool rotate;
591         //
592         // for long tabulars
593         //
594         bool is_long_tabular;
595         /// endhead data
596         ltType endhead;
597         /// endfirsthead data
598         ltType endfirsthead;
599         /// endfoot data
600         ltType endfoot;
601         /// endlastfoot data
602         ltType endlastfoot;
603
604         ///
605         void init(BufferParams const &, row_type rows_arg,
606                   col_type columns_arg);
607         ///
608         void set_row_column_number_info();
609         /// Returns true if a complete update is necessary, otherwise false
610         bool setWidthOfMulticolCell(idx_type cell, int new_width);
611         ///
612         void recalculateMulticolumnsOfColumn(col_type column);
613         /// Returns true if change
614         void calculate_width_of_column(col_type column);
615         ///
616         bool calculate_width_of_column_NMC(col_type column); // no multi cells
617         ///
618         void calculate_width_of_tabular();
619         ///
620         void delete_column(col_type column);
621         ///
622         idx_type cells_in_multicolumn(idx_type cell) const;
623         ///
624         BoxType useParbox(idx_type cell) const;
625         ///
626         // helper function for Latex returns number of newlines
627         ///
628         int TeXTopHLine(odocstream &, row_type row) const;
629         ///
630         int TeXBottomHLine(odocstream &, row_type row) const;
631         ///
632         int TeXCellPreamble(odocstream &, idx_type cell) const;
633         ///
634         int TeXCellPostamble(odocstream &, idx_type cell) const;
635         ///
636         int TeXLongtableHeaderFooter(odocstream &, Buffer const & buf,
637                                      OutputParams const &) const;
638         ///
639         bool isValidRow(row_type const row) const;
640         ///
641         int TeXRow(odocstream &, row_type const row, Buffer const & buf,
642                    OutputParams const &) const;
643         ///
644         // helper functions for plain text
645         ///
646         bool plaintextTopHLine(odocstream &, row_type row,
647                                std::vector<unsigned int> const &) const;
648         ///
649         bool plaintextBottomHLine(odocstream &, row_type row,
650                                   std::vector<unsigned int> const &) const;
651         ///
652         void plaintextPrintCell(Buffer const &, odocstream &,
653                                 OutputParams const &,
654                                 idx_type cell, row_type row, col_type column,
655                                 std::vector<unsigned int> const &,
656                                 bool onlydata) const;
657         /// auxiliary function for docbook
658         int docbookRow(Buffer const & buf, odocstream & os, row_type,
659                        OutputParams const &) const;
660
661 private:
662         /// renumber cells after structural changes
663         void fixCellNums();
664 };
665
666
667
668 class InsetTabular : public Inset {
669 public:
670         ///
671         InsetTabular(Buffer const &, row_type rows = 1,
672                      col_type columns = 1);
673         ///
674         ~InsetTabular();
675         ///
676         void read(Buffer const &, Lexer &);
677         ///
678         void write(Buffer const &, std::ostream &) const;
679         ///
680         bool metrics(MetricsInfo &, Dimension &) const;
681         ///
682         void draw(PainterInfo & pi, int x, int y) const;
683         ///
684         void drawSelection(PainterInfo & pi, int x, int y) const;
685         ///
686         virtual docstring const editMessage() const;
687         ///
688         EDITABLE editable() const { return HIGHLY_EDITABLE; }
689         ///
690         bool insetAllowed(Inset::Code) const { return true; }
691         ///
692         bool allowSpellCheck() const { return true; }
693         ///
694         bool canTrackChanges() const { return true; }
695         /** returns true if, when outputing LaTeX, font changes should
696             be closed before generating this inset. This is needed for
697             insets that may contain several paragraphs */
698         bool noFontChange() const { return true; }
699         ///
700         DisplayType display() const { return tabular.isLongTabular() ? AlignCenter : Inline; }
701         ///
702         int latex(Buffer const &, odocstream &,
703                   OutputParams const &) const;
704         ///
705         int plaintext(Buffer const &, odocstream &,
706                       OutputParams const &) const;
707         ///
708         int docbook(Buffer const &, odocstream &,
709                     OutputParams const &) const;
710         ///
711         void validate(LaTeXFeatures & features) const;
712         ///
713         Code lyxCode() const { return Inset::TABULAR_CODE; }
714         /// get offset of this cursor slice relative to our upper left corner
715         void cursorPos(BufferView const & bv, CursorSlice const & sl,
716                 bool boundary, int & x, int & y) const;
717         ///
718         bool tabularFeatures(Cursor & cur, std::string const & what);
719         ///
720         void tabularFeatures(Cursor & cur, Tabular::Feature feature,
721                              std::string const & val = std::string());
722         ///
723         void openLayoutDialog(BufferView *) const;
724         ///
725         bool showInsetDialog(BufferView *) const;
726         /// number of cells
727         size_t nargs() const { return tabular.getNumberOfCells(); }
728         ///
729         boost::shared_ptr<InsetText const> cell(idx_type) const;
730         ///
731         boost::shared_ptr<InsetText> cell(idx_type);
732         ///
733         Text * getText(int) const;
734
735         /// set the change for the entire inset
736         void setChange(Change const & change);
737         /// accept the changes within the inset
738         void acceptChanges(BufferParams const & bparams);
739         /// reject the changes within the inset
740         void rejectChanges(BufferParams const & bparams);
741
742         // this should return true if we have a "normal" cell, otherwise false.
743         // "normal" means without width set!
744         /// should all paragraphs be output with "Standard" layout?
745         bool forceDefaultParagraphs(idx_type cell = 0) const;
746
747         ///
748         void addPreview(graphics::PreviewLoader &) const;
749
750         ///
751         Buffer const & buffer() const;
752
753         /// set the owning buffer
754         void buffer(Buffer const * buf);
755         /// lock cell with given index
756         void edit(Cursor & cur, bool left);
757         ///
758         Inset * editXY(Cursor & cur, int x, int y);
759         /// can we go further down on mouse click?
760         bool descendable() const { return true; }
761
762         //
763         // Public structures and variables
764         ///
765         mutable Tabular tabular;
766
767 protected:
768         ///
769         InsetTabular(InsetTabular const &);
770         ///
771         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
772         ///
773         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
774         ///
775         int scroll() const { return scx_; }
776
777 private:
778         virtual std::auto_ptr<Inset> doClone() const;
779
780         ///
781         void drawCellLines(frontend::Painter &, int x, int y, row_type row,
782                            idx_type cell, bool erased) const;
783         ///
784         void setCursorFromCoordinates(Cursor & cur, int x, int y) const;
785
786         ///
787         void moveNextCell(Cursor & cur);
788         ///
789         void movePrevCell(Cursor & cur);
790         ///
791         int getCellXPos(idx_type cell) const;
792         ///
793         void resetPos(Cursor & cur) const;
794         ///
795         void removeTabularRow();
796         ///
797         bool copySelection(Cursor & cur);
798         ///
799         bool pasteClipboard(Cursor & cur);
800         ///
801         void cutSelection(Cursor & cur);
802         ///
803         bool isRightToLeft(Cursor & cur) const;
804         ///
805         void getSelection(Cursor & cur, row_type & rs, row_type & re,
806                           col_type & cs, col_type & ce) const;
807         ///
808         bool insertPlaintextString(BufferView &, docstring const & buf, bool usePaste);
809         /// are we operating on several cells?
810         bool tablemode(Cursor & cur) const;
811
812         /// return the "Manhattan distance" to nearest corner
813         int dist(BufferView &, idx_type cell, int x, int y) const;
814         /// return the cell nearest to x, y
815         idx_type getNearestCell(BufferView &, int x, int y) const;
816
817         /// test the rotation state of the give cell range.
818         bool oneCellHasRotationState(bool rotated,
819                                 row_type row_start, row_type row_end,
820                                 col_type col_start, col_type col_end) const;
821         ///
822         Buffer const * buffer_;
823         ///
824         mutable idx_type first_visible_cell;
825         ///
826         mutable int scx_;
827 };
828
829
830 class InsetTabularMailer : public MailInset {
831 public:
832         ///
833         InsetTabularMailer(InsetTabular const & inset);
834         ///
835         virtual Inset & inset() const { return inset_; }
836         ///
837         virtual std::string const & name() const { return name_; }
838         ///
839         virtual std::string const inset2string(Buffer const &) const;
840         ///
841         static void string2params(std::string const &, InsetTabular &);
842         ///
843         static std::string const params2string(InsetTabular const &);
844 private:
845         ///
846         static std::string const name_;
847         ///
848         InsetTabular & inset_;
849 };
850
851 std::string const featureAsString(Tabular::Feature feature);
852
853 } // namespace lyx
854
855 #endif